I\'m developing a program that has many buttons that should do a similar action when clicked, but with a small difference based on which button was clicked. The problem is t
Assign the same event handler to all buttons.
foreach (var button in Controls.OfType
Or you can select the same event handler in the properties window switched to events (flash icon).
private static void button_Click(object sender, EventArgs eventArgs)
{
switch (((Button)sender).Name)
{
// find a way to disambiguate.
}
}
You can also add some useful information to the Tag property for the disambiguation. And last but not least, you can derive your own button from Button and add appropriate properties. They will even appear in the properties window.