首页 > 编程语言 > 详细

【C#笔记】控件数组与事件

时间:2015-07-17 15:51:59      阅读:231      评论:0      收藏:0      [点我收藏+]
private void Form1_Load(object sender, EventArgs e)
        {
            
           Button[] but = new Button[10];

            for (int i = 0; i < 10; i++)
            {
                but[i] = new Button();
                but[i].Text = "按钮" + i;
                but[i].Left = 82 * i;
                but[i].Width = 80;
                this.Controls.Add(but[i]);
                but[i].Click += new System.EventHandler(this.but_Click);//绑定事件
            }
            
        private void but_Click(object sender,System.EventArgs e)
        {
            MessageBox.Show(((Button)sender).Text+"01");//用sender 判定是那个控件
        }

            
        }

 

【C#笔记】控件数组与事件

原文:http://www.cnblogs.com/laoshuboke/p/4654593.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!