如何删除某个控件的事件

           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);

你可能感兴趣的:(object,null,button,events)