Hi.
I have an array of buttons that I fire MouseClick event for them in Form1_Load method.
In Button_MouseClick method, How Can I understand What is the index of button that is pressed?(pressed button is one of aforementioned array members)
Can I change signature of Button_MouseClick event and add an int parameter to end of it as index?
Thanks :-)
Loading

Mike GoldPosted Sep 2, 2010, 11:06 PM
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show((sender as Button).Name);
}
ShankeyPosted Sep 3, 2010, 2:23 AM
You can use
CommandName="1" where 1 is the index of the button and OnCommand="btn_Command" is the event method to call when any button from the array is clicked. You can further read about CommandName and OnCommand properties of link button
Dont forget to mark my answer as accepted if it helped you