myButton1.Click += new MyButtonClick;
myButton2.Click += new MyButtonClick;
myButton3.Click += new MyButtonClick;
myButton4.Click += new MyButtonClick;
myButton5.Click += new MyButtonClick;
myButton6.Click += new MyButtonClick;
void MyButtonClick(object sender, EventArgs e)
{
Button button = sender as Button;
//here you can check which button was clicked by the sender
}
myButton1.Click += new EventHandler(MyButtonClick);
myButton2.Click += new EventHandler(MyButtonClick);
myButton3.Click += new EventHandler(MyButtonClick);
myButton4.Click += new EventHandler(MyButtonClick);
myButton5.Click += new EventHandler(MyButtonClick);
myButton6.Click += new EventHandler(MyButtonClick);
public void MyButtonClick(object sender, MouseButtonEventArgs e)
{
switch ((sender as Button).Name)
{
case "button1":
//actions
break;
case "button2":
//actions
break;
default:
break;
}
}