1用反射
PropertyInfo pi = (typeof(Button)).GetProperty("Events", BindingFlags.Instance | BindingFlags.NonPublic); EventHandlerList ehl = (EventHandlerList)pi.GetValue(btnHardInfo, null);//这是你的Button 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++) { MsgBox.Items.Add(dels[i].Method.Name);//这里会输出所有方法名称 } }
2只要在加事件之前先-=就可以了
button2.Click -= new EventHandler(button2_Click);
button2.Click += new EventHandler(button2_Click);