C#新增按钮
2021-06-05 20:03
标签:and text int sage parent i++ message bre click C#新增按钮 标签:and text int sage parent i++ message bre click 原文地址:https://www.cnblogs.com/qiu18359243869/p/10799228.html
form_load段:
for (int i = 0; i {
btn = new Button();
btn.Parent = this.panel1;
//btn.Top = 25 * i;
btn.Name = "btn" + i.ToString();
btn.Text = "btn" + i.ToString();
btn.Click += new EventHandler(btn_Click);
}
void btn_Click(object sender, EventArgs e)
{
//MessageBox.Show("" + ((Button)sender).Name);
string name = ((Button)sender).Name;
switch (name)
{
case "btn0":
//btn0处理代码
break;
case "btn1":
//处理代码
break;
case "btn2":
//处理代码
break;
//继续添加
上一篇:WPF疑难杂症之一(3D场景)