Help Required in Events
Dear Friends
I am the beginner in the C# and currently working on event handling. I have created an array of buttons and placed them on the form. how can I do the event handling in this case for individual button.
my code to create buttons is as follow with an array.
for (int i = 0; i < num_of_buttons; i++)
{
for (int j = 0; j < num_of_buttons; j++)
{
this.b[i, j] = new Button();
this.b[i, j].Name = "B " + m;
this.b[i, j].Text = "B " + m;
this.b[i, j].Location = new Point(k, l);
this.b[i, j].Size = new Size(30, 30);
this.b[i, j].TabIndex = m;
this.Controls.Add(this.b[i, j]);
}
}
Please help me in solving this problem.
Waqar AhmedPosted Feb 19, 2006, 5:51 PM
Ashish SinghalPosted Feb 18, 2006, 7:10 PM
Where you create button and define its properties , with that code you can write you event handle code too , like Button btn = new Button(); btn.Click += new EventHandler(Click); now it's
upto you that you want seprate function param for each button click or you just wana catch all in one function, if you catch in one then cast sender to button and on ID you can process your event.
private void Click(object sender, eventargs e)
{
}