public void CreateCtrls() { Button[] name = new Button[number]; //控件可以随意设置,比如:CheckBox,TextBox等 for (int i = 0; i < number; i++) { name[i] = new Button(); name[i].Location = new Point(20, 100 + i * 30);//位置根据需要调整 name[i].Size = new Size(200, 30);//大小根据需要调整 name[i].tag=i; name[i]=i.tostring(); name[i].Click += new EventHandler(clickMethod); this.Controls.Add(name[i]); } } public void clickMethod(object sender, EventArgs e) { Button btt = (Button)sender; btt.name//接下来自由发挥吧 }
已有 4330 位网友参与,快来吐槽:
发表评论