码迷,mamicode.com
首页 > 其他好文 > 详细

(CSharp)克隆控件事件

时间:2017-08-03 21:49:34      阅读:307      评论:0      收藏:0      [点我收藏+]

标签:nts   控件   button   clone   ons   ack   事件   and   color   

// 假设有 button1 和 button2 两个按钮,下面代码实现从 button1 克隆事件到 button2
// 原文:https://stackoverflow.com/questions/6055038/how-to-clone-control-event-handlers-at-run-time
FieldInfo eventsField = typeof(Component).GetField("events", BindingFlags.NonPublic | BindingFlags.Instance);
object eventHandlers = eventsField.GetValue(button1);
eventsField.SetValue(button2, eventHandlers);

 

(CSharp)克隆控件事件

标签:nts   控件   button   clone   ons   ack   事件   and   color   

原文地址:http://www.cnblogs.com/Bob-wei/p/7281502.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!