If you want to do it for all controls dynamically you can navigate through the controls tree and subscribe the same event handler for events like shown below, in case of predefined controls set basically just subscribe all of them for the same even handlers.
Predefined controls set
checkBox1.CheckedChanged += (s, e) => { /* handles Checked state changes*/ };
button1.Click += (s, e) => { /* handles button click */ };
Dynamic
private void InitializeHooks()
{
foreach(var control in this.Controls)
{
var button = control as Button;
if (button != null)
{
button.Click += OnClick;
continue;
}
var checkBox = control as CheckBox;
if (checkBox != null)
{
checkBox.CheckedChanged += OnCheckedChanged;
}
}
}
// Button click handler
private void OnClick(object sender, EventArgs eventArgs)
{
txtOutput.Text = String.Format(
CultureInfo.CurrentCulture,
"{Control Type: {0}, Name: {1}, Event: Click",
sender.GetType().Name,
sender.Id);
}
// Checkbox Checked state changed handler
private void OnCheckedChanged(object sender, EventArgs eventArgs)
{
txtOutput.Text = String.Format(
CultureInfo.CurrentCulture,
"{Control Type: {0}, Name: {1}, Event: CheckedChanged",
sender.GetType().Name,
sender.Id);
}