using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; namespace TestDev { class Program { static void Main(string[] args) { System.Windows.Forms.Button btn = new System.Windows.Forms.Button(); btn.Click += new EventHandler(btn_Click); btn.Click += new EventHandler(btn_Click2); btn.Click += new EventHandler(btn_Click3); btn.MouseMove += btn_MouseMove; btn.MouseMove += btn_MouseMove2; PropertyInfo pi = btn.GetType().GetProperty("Events", BindingFlags.Instance | BindingFlags.NonPublic); EventHandlerList ehl = (EventHandlerList)pi.GetValue(btn, null);//EventClick FieldInfo fieldInfo = (typeof(System.Windows.Forms.Control)).GetField("EventMouseMove", BindingFlags.Static | BindingFlags.NonPublic); Delegate d = ehl[fieldInfo.GetValue(null)]; foreach (Delegate del in d.GetInvocationList()) Console.WriteLine(del.Method.Name); } static void btn_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { throw new NotImplementedException(); } static void btn_MouseMove2(object sender, System.Windows.Forms.MouseEventArgs e) { throw new NotImplementedException(); } static void btn_Click(object sender, EventArgs e) { Console.WriteLine("Click1"); } static void btn_Click2(object sender, EventArgs e) { Console.WriteLine("Click2"); } static void btn_Click3(object sender, EventArgs e) { Console.WriteLine("Click3"); } } }
没有整理与归纳的知识,一文不值!高度概括与梳理的知识,才是自己真正的知识与技能。 永远不要让自己的自由、好奇、充满创造力的想法被现实的框架所束缚,让创造力自由成长吧! 多花时间,关心他(她)人,正如别人所关心你的。理想的腾飞与实现,没有别人的支持与帮助,是万万不能的。
本文转自wenglabs博客园博客,原文链接:http://www.cnblogs.com/arxive/p/6932445.html
,如需转载请自行联系原作者