FieldInfo keyfi = typeof(Control).GetField("EventClick", BindingFlags.Static | BindingFlags.NonPublic);
object eventkey = keyfi.GetValue(button1);
// Get the protected Events property
PropertyInfo evtpi = typeof(Control).GetProperty("Events", BindingFlags.Instance | BindingFlags.NonPublic);
EventHandlerList evts = (EventHandlerList)evtpi.GetValue(button1, null);
// Obtain the value of the delegate and remove it
Delegate dlg = evts[eventkey];
evts.RemoveHandler(eventkey, dlg);
如何删除某个控件的事件
最新推荐文章于 2022-11-25 10:39:36 发布