Type t = button1.GetType();
            PropertyInfo pi 
= t.GetProperty("Events", BindingFlags.Instance | BindingFlags.NonPublic);
            EventHandlerList ehl 
= (EventHandlerList)pi.GetValue(button1, null);
            FieldInfo fieldInfo 
= (typeof(Control)).GetField("EventClick", BindingFlags.Static | BindingFlags.NonPublic);
            Delegate d 
= ehl[fieldInfo.GetValue(null)];
            
if (d != null)
            {
                
foreach (Delegate temp in d.GetInvocationList())
                {
                    ehl.RemoveHandler(fieldInfo.GetValue(
null), temp);
                }
            }
这个方法适合在不知道委托事件的详细情况下,取消所有的委托事件。。

相关文章:

  • 2022-01-15
  • 2022-12-23
  • 2021-05-21
  • 2021-08-01
  • 2021-07-13
  • 2021-11-10
猜你喜欢
  • 2021-08-09
  • 2021-07-28
  • 2021-09-01
  • 2021-09-04
  • 2022-01-26
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案