Skip to content

Instantly share code, notes, and snippets.

@DinisCruz
Created June 13, 2012 14:43
Show Gist options
  • Select an option

  • Save DinisCruz/2924498 to your computer and use it in GitHub Desktop.

Select an option

Save DinisCruz/2924498 to your computer and use it in GitHub Desktop.
O2 Script to Removing an Event from a WinForm control using reflection
//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