Hello
Add it in the Constructor. Create a new class that inherits from Button
public class MyButton : System.Windows.Forms.Button
{
public MyButton()
{
this.Click += new EventHandler(MyButton_Click);
}
void MyButton_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello");
}
}
Of course I like it:
public class MyButton : System.Windows.Forms.Button
{
public MyButton()
{
this.Click += new EventHandler(
(object sender, EventArgs e) =>
{
MessageBox.Show("Hello");
});
}
}