{ x = 30; for (int i = 0; i < ar.Length; i++) { bu[index1] = new Button(); bu[index1].Location = new Point(50, x); bu[index1].Size = new Size(75, 20); bu[index1].Text = "1"; bu[index1].Name = b+ i; bu[index1].Click += new EventHandler(button_Click1); x = x + 100; index1++; } this.Controls.AddRange(bu); } private void button_Click1(object sender, EventArgs e) { if(bu[0].Name=="b0") MessageBox.Show("selected rw1"); else if(bu[1].Name=="b1") MessageBox.Show("selected rw2"; }
sender
private void button_Click1(object sender, EventArgs e) { Button selected = sender as Button; MessageBox( selected.Name); }
bu[index1].Name = "b" + i;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)