用委托,比如在面板上再添加一个Button
Button btn = new Button();
btn.Name = "btnOk";
btn.Text = "确定";
btn.Click += new EventHandler(btn_Click);
this.panel1.Controls.Add(btn);
private void btn_Click(object sender, EventArgs e)
{
//按钮btnOk的点击事件
}
双击控件,即加了Click事件,