日期:2014-05-17 浏览次数:20965 次
panel1.DoubleClick += new EventHandler(
(sender1, e1)=>
{
//......
Type t = panel1.GetType();
PropertyInfo pi = t.GetProperty("Events", BindingFlags.Instance
------解决方案--------------------
BindingFlags.NonPublic);
EventHandlerList ehl = (EventHandlerList)pi.GetValue(panel1, null);
FieldInfo fieldInfo = (typeof(Control)).GetField("EventDoubleClick", BindingFlags.Static
------解决方案--------------------
BindingFlags.NonPublic);
Delegate d = ehl[fieldInfo.GetValue(null)];
if (d != null)
{
foreach (Delegate temp in d.GetInvocationList())
{
StackTrace st = new StackTrace(true);
if (temp.Method == st.GetFrame(0).GetMethod())
ehl.RemoveHandler(fieldInfo.GetValue(null), temp);
}
}
}
);