Possible Duplicate:
Is it possible to “steal” an event handler from one control and give it to another?
Is there a way to get references of the event handlers from the event?
For example:
EventHandler evt = btn.Click; // or another way ?
(Here the EventHandler
is the delegate and Click
is an event of Button)
If you defined the event and your code that accesses it is in the same class (i.e. not derived) then you can access it and get the invocation list.
MulticastDelegate m = (MulticastDelegate)MyEvent;
var list = m.GetInvocationList();
foreach(Delegate d in list)
{
// look at the delegate
}
http://www.c-sharpcorner.com/UploadFile/rmcochran/csharp_events01292006081130AM/csharp_events.aspx
http://social.msdn.microsoft.com/Forums/eu/csharplanguage/thread/9a58321d-7fd5-45ca-bba0-44a0a336aeeb
For the case where you want to access the invocation list of an event defined in a class whose code you can't modify...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With