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 判定是那个控件
        }

            
        }

 

相关文章:

  • 2021-05-31
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2021-09-20
  • 2021-10-11
  • 2021-08-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-08-23
  • 2022-02-01
  • 2022-03-01
  • 2021-11-06
相关资源
相似解决方案