Tobias Müller said:
This is definitely not needed and IMO an indirection too much.
The name of an event handler does not have to be objectName_EventName(),
thats just the default if you generate the handler by double clicking the
event in VS designer.
There is absolutely no problem using the same handler for two different
buttons. If you have a button 'whateverButton' with handler
'whateverButton_Click', you can create a second button 'someOtherButton'
and also use 'whateverButton_Click' as handler.
In the 'events' pane (the little lightning bolt) in VS designer you
cannot
just double click to create an event handler but also use the drop down
menu to choose an existing one.
Perhaps I was mixing two threads. I agree that if you have multiple controls
which should react in a similar way to an event then there is no problem
with writing a single event handler and then wiring the controls to that
event handler. (I've done this myself on more than one occasion.)
What I was thinking of was when you also want to call the event handler from
other parts of the code. This is probably where my mind drifted into a
different thread and I posted the "completely separate method" concept. Of
course, if you have even the tiniest bit of variation (like button 1 does x,
y, and z, and button 2 does x, y, z, and w), you would want to consider
whether or not to have the event handler perform that logic or whether to
pull all the common logic into a separate method and then do the extra stuff
in separate, control-specific event handlers.