for (int i = 1; i < 5; i++)
{
for (int j = 1; j < 5; j++)
{
Button btn = new Button();
btn.Text = j.ToString() + "0" + i.ToString();
btn.Size = new Size(100, 130);
btn.Left = 145+ (i-1) * 100;
btn.Top = 20 + (j-1) * 140;
btn.BackColor = Color.Blue;
this.Controls.Add(btn);
}
}
如何定义这些button的单击事件,请高手指教
{
for (int j = 1; j < 5; j++)
{
Button btn = new Button();
btn.Text = j.ToString() + "0" + i.ToString();
btn.Size = new Size(100, 130);
btn.Left = 145+ (i-1) * 100;
btn.Top = 20 + (j-1) * 140;
btn.BackColor = Color.Blue;
this.Controls.Add(btn);
}
}
如何定义这些button的单击事件,请高手指教
{
Button me=sender as Button;//取得被点击的button对象,
}
// button1
//
this.button1.Location = new System.Drawing.Point(-2, 155);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 1;
this.button1.Text = "button1";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);