昨夜飘风
昨 夜, 风, 飘 过; 枯 树, 叶, 飞 落。
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);
                }
            }
这个方法适合在不知道委托事件的详细情况下,取消所有的委托事件。。
posted on 2008-07-31 15:23  昨夜飘风  阅读(2204)  评论(1编辑  收藏  举报