具体的理论就不说了,上一篇博文大概介绍了,这里就直接上主要的代码吧:
Control _Button = this.Controls["button1"]; //获取窗体中的button1
System.Reflection.MethodInfo _Info = this.GetType().GetMethod("button1_Click"); //获取按钮单击事件的方法
Delegate _Click = Delegate.CreateDelegate(typeof(EventHandler), this, _Info); //新建委托
_Button.GetType().GetEvent("Click").AddEventHandler(_Button, _Click);新建委托