Is there a way to list all fired events for specific WinForms controls without explicitly creating a handler for each possible event? For example, I might want to see the sequence of events that fire between a DataGridView and the BindingSource during various databinding actions.
Share
You could use reflection, but it’s going to be slightly tricky because of the various event handler signatures involved. Basically you’d have to get the
EventInfofor each event in the type, and use theEventHandlerTypeproperty to work out what delegate type to create before callingAddEventHandler.Delegate.CreateDelegateworks for everything that follows the normal event handler pattern though…Here’s a sample app. Note that it’s not doing any checking – if you give it something with a ‘non-standard’ event it will throw an exception. You could fairly easily use reflection to print out the event args too.