public partial class Form1 : Form { public Form1() { InitializeComponent(); this.button1.Click += new System.EventHandler(this.button1_Click); } private void button1_Click(object sender, EventArgs e) { MessageBox.Show("Hello World"); } }If you created the handler by doubleclicking on the button (or from the Properties window) then the
this.button1.Click += new System.EventHandler(this.button1_Click);line would be automatically added to the InitializeComponent() method - you can check this by looking in the Form1.Designer.cs file (all this assuming your form IS called Form1 of course)