Is there a way to find all event handlers for a Winforms control? Specifically statically defined event handlers?
Windows Forms controls use an EventHandlerList
property called Events
to hold event handlers so you could iterate that collection. To determine which subscribed handlers are static, you will need to use reflection.
Windows Forms has strong counter-measures against doing this. Most controls store the event handler reference in a list that requires a secret 'cookie'. The cookie value is dynamically created, you cannot guess it up front. Reflection is a backdoor, you have to know the cookie variable name. The one for the Control.Click event is named "EventClick" for example, you can see this in the Reference Source or with Reflector.
This is all incredibly unpractical, if you're getting the feeling you are doing something unwise then you're on the right track. You can find sample code that does this in my answer in this thread.