kinda difficult to explain but is there a way to do something like:
control1.ShownEditor += EventHandler;
...
control2.ShownEditor += control1.ShownEditor; //wrong
kinda difficult to explain but is there a way to do something like:
control1.ShownEditor += EventHandler;
...
control2.ShownEditor += control1.ShownEditor; //wrong
Save your event to a EventHandler delegate.
EventHandler Myevent = () => {/*event handling code here*/};
Assign the event handler delegate to the control events
control1.ShownEditor += Myevent;
control2.ShownEditor += Myevent;
Simply: you cannot use an EventHandler
of a control's event and assign it to another event. So this isn't possible:
control2.ShownEditor += control1.ShownEditor; //wrong
The only way is to create an EventHandler
separately and assign it to both the controls' event.
Another harmful solution could be extract the delegate via Reflection
, but as I said it's actually dangerous, look this answer by Hans Passant: Is it possible to “steal” an event handler from one control and give it to another?.