110,565
社区成员
发帖
与我相关
我的任务
分享
PropertyInfo pi = (typeof(System.Windows.Forms.Button)).GetProperty("Events",
BindingFlags.Instance | BindingFlags.NonPublic);
EventHandlerList ehl = (EventHandlerList)pi.GetValue(button5, null);
FieldInfo fi = (typeof(Control)).GetField("EventClick", BindingFlags.Static | BindingFlags.NonPublic);
Delegate d = ehl[fi.GetValue(null)];
if (d != null)
{
System.Delegate[] dels = d.GetInvocationList();
for (int i = 0; i < dels.Length; i++)
{
if (i < 3)
{
this.button5.Click -= (EventHandler)dels[i];
}
}
}
this.Click += new EventHandler(Form1_Click);
this.Click -= new EventHandler(Form1_Click);