I have a button control, and I\'d need to remove all the event handlers attached to its Click event.
How would that be possible?
Button button = GetB
I found this answer here on StackOverflow:
How to remove all event handlers from a control
private void RemoveClickEvent(Button b)
{
FieldInfo f1 = typeof(Control).GetField("EventClick",
BindingFlags.Static | BindingFlags.NonPublic);
object obj = f1.GetValue(b);
PropertyInfo pi = b.GetType().GetProperty("Events",
BindingFlags.NonPublic | BindingFlags.Instance);
EventHandlerList list = (EventHandlerList)pi.GetValue(b, null);
list.RemoveHandler(obj, list[obj]);
}
Which the origional poster found here: