private void Form1_Load(object sender, EventArgs e)

{
this.Width = 350;
this.Height = 250;

Button[] buttons = new Button[3];
for (int i = 0; i < buttons.Length; i++)
{
buttons[i] = new Button();
buttons[i].Name = "button" + i;
buttons[i].Text = buttons[i].Name;
buttons[i].Location = new Point(10, 30 * i);
buttons[i].Click += new EventHandler(Buttons_Click);
}
this.Controls.AddRange(buttons);
}
void Buttons_Click(object sender, EventArgs e)
{
this.Text = (sender as Button).Text;
}

文章標籤
全站熱搜
創作者介紹
創作者 nusection 的頭像
nusection

Nu Section

nusection 發表在 痞客邦 留言(0) 人氣(8,465)