I have 6 buttons that I want to be attached to the same handler. How can I do this?
I have 6 buttons that I want to be attached to the same handler. How can I do this?
button1.Click += button_Click;
button2.Click += button_Click;
void button_Click(object sender, EventArgs e)
{
if (sender == button1)
{
this.Text = "1";
}
else if (sender == button2)
{
this.Text = "2";
}
}