110,571
社区成员
发帖
与我相关
我的任务
分享
btn[i].Click += new System.EventHandler(this.buttonCus_Click);private void button1_Click(object sender, EventArgs e)
{
Button[] btn = new Button[10];
for (int i = 0; i < 10; i++)
{
btn[i] = new Button();
btn[i].Text = i.ToString();
btn[i].Location = new Point(0, (10 - i) * btn[i].Height);
this.Controls.Add(btn[i]);
btn[i].Click += new System.EventHandler(this.buttonCus_Click);
}
}
private void buttonCus_Click(object sender, EventArgs e)
{
MessageBox.Show("这是第"+((Button)sender).Text+"个button");
}