Created
June 13, 2012 14:43
-
-
Save DinisCruz/2924498 to your computer and use it in GitHub Desktop.
O2 Script to Removing an Event from a WinForm control using reflection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //for a UserControl (in fact any control that implements System.ComponentModel.Component) | |
| var userControl = new UserControl(); | |
| //we can get the current mapped event handlers | |
| userControl.eventHandlers(); | |
| //its signature | |
| userControl.eventHandlers_MethodSignatures(); | |
| //remove one by using the static field name | |
| userControl.remove_EventHandler("EVENT_SELECTEDINDEXCHANGED"); | |
| //or use this one specifically mapped to the SelectedIndexChanged event | |
| userControl.remove_Event_SelectedIndexChanged |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment