this.button1.Click += new System.EventHandler(this.button1_Click);//委托调用相关的程序
private void button1_Click(object sender, System.EventArgs e)
{
…
}
///////////////////////////////////
委托的形式如下
[修饰符] delegate 返回类型 委托名称(参数列表)
public delegate void AlarmEventHandler(object sender, AlarmEventArgs e);
///////////////////////
在运行时添加和移除事件处理程序
this.button2.Click += new
System.EventHandler(this.button1_Click);
this.button2.Click -= new
System.EventHandler(this.button1_Click);