using System.Reflection;
using System.ComponentModel;

PropertyInfo property = (typeof(控制項的類別)).GetProperty("Events", BindingFlags.Instance | BindingFlags.NonPublic);
EventHandlerList ehList = (EventHandlerList)property.GetValue(控制項的ID, null);

此時ehList就如控制項裡base.Events的角色,可以讀取此控制項目前載入的事件

如要在細分就用

FieldInfo field = (typeof(Control)).GetField("Event"+控制項event的名字(不是方法名), BindingFlags.Static | BindingFlags.NonPublic);
Delegate d =ehList[field.GetValue(null)];
if (d != null) {
foreach (Delegate temp in d.GetInvocationList())
 {
 temp.Method.Name(就是方法名了)
 }
 }
arrow
arrow
    全站熱搜

    caramels 發表在 痞客邦 留言(0) 人氣()