C#获取按钮的EventClick事件,EventHandlerList委托的调用列表
C#获取按钮的EventClick事件,EventHandlerList委托的调用列表
扫一扫加微信
C# Code:
//获取按钮的Click事件
System.Reflection.PropertyInfo propertyInfo = (typeof(Control)).GetProperty("Events", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
System.Reflection.FieldInfo fieldInfo = (typeof(Control)).GetField("EventClick", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
EventHandlerList eventHandlerList = (EventHandlerList)propertyInfo.GetValue(Refbtn, null);
Delegate d = eventHandlerList[fieldInfo.GetValue(null)];
if (d != null)
{
foreach (Delegate temp in d.GetInvocationList())//委托的调用列表
{
btn.Click += (EventHandler)temp;
}
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
System.Reflection.PropertyInfo propertyInfo = (typeof(Control)).GetProperty("Events", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
System.Reflection.FieldInfo fieldInfo = (typeof(Control)).GetField("EventClick", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic);
EventHandlerList eventHandlerList = (EventHandlerList)propertyInfo.GetValue(Refbtn, null);
Delegate d = eventHandlerList[fieldInfo.GetValue(null)];
if (d != null)
{
foreach (Delegate temp in d.GetInvocationList())//委托的调用列表
{
btn.Click += (EventHandler)temp;
}
}
//来源:C/S框架网 | www.csframework.com | QQ:23404761
扫一扫加微信
版权声明:本文为开发框架文库发布内容,转载请附上原文出处连接
NewDoc C/S框架网