查看控件的事件绑定

Posted on 2014-11-04 17:57  云起  阅读(6)  评论(0)    收藏  举报  来源
            System.Reflection.PropertyInfo propertyInfo = (typeof(Control)).GetProperty("Events", BindingFlags.Instance | BindingFlags.NonPublic);
            EventHandlerList eventHandlerList = (EventHandlerList)propertyInfo.GetValue(this.axMapControl2 as Control, null);
            System.Reflection.FieldInfo fieldInfo = (typeof(Control)).GetField("EventMouseEnter", BindingFlags.Static | BindingFlags.NonPublic);
            Delegate d = eventHandlerList[fieldInfo.GetValue(null)];
            if (d != null)
            {
                foreach (Delegate temp in d.GetInvocationList())
                {
                    Console.WriteLine(temp.Method.Name);
                }
            }

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3