windows forms on button click event code example

Example 1: windows form button click

private void button1_Click(object sender, System.EventArgs e)  
{  
   MessageBox.Show("button1 was clicked");  
}

Example 2: windows forms add onclick

button.Click += (sender, e)=> {
  // In here, you can access prodData1 and prodData2
};

// Or

button.Click += ClickMethod;

// Or 

string extraParamenter = ""; // This extra paremeter can be any type
button.Click += ClickMethod(sender, e, extraParamenter);