Skip to content

Instantly share code, notes, and snippets.

View Loys's full-sized avatar
💭
I may be slow to respond.

Loys

💭
I may be slow to respond.
View GitHub Profile
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]);
}
public void RemoveAllEvents(Control c)