Button btn = new Button();
btn.Size = new Size(50, 30);
btn.Location = new Point(100, 100);
btn.Name = "btn";
btn.Text = "Button";
this.Controls.Add(btn);
//設置事件
btn.addEventListener(MouseEvent.CLICK, onClickHandler);
...
private void btn_Click(object sender, EventArgs e)
{
······
}