int a, b;
private void Form1_Load(object sender, EventArgs e)
{
this.Width = 600;
this.Height = 436;
for (a = 1; a <= 8; a++)
{
for (b = 1; b <= 8; b++)
{
Button btn = new Button();
btn.Name = (((a - 1) * 8) + b).ToString();
btn.Width = 50;
btn.Height = 50;
btn.Left = (b - 1) * 50;
btn.Top = (a - 1) * 50;
if ((a + b) % 2 == 0)
btn.BackColor = Color.WhiteSmoke;
else
btn.BackColor = Color.Black;
btn.Click += new EventHandler(btn_Click);
this.Controls.Add(btn);
}
}
}
int i, j,y;
void btn_Click(object sender, EventArgs e)
{
Button btn = (Button)sender;
if (radioButton1.Checked == true)
{
i = int.Parse(btn.Name);
j = i % 8;
for (y = 1; y <= 8; j+=8)
{
}
}
我該如何更改其他按鈕backcolor?c#win應用程序
魔法門想要改寫問題,讓人們知道你在做什麼。 – Dismissile 2010-10-19 18:08:19
任何人都有一個或兩個關於變量範圍的好鏈接?我猜這是從.cs文件中刪除的...... – 2010-10-19 18:14:13
@ user400065:您似乎已經知道如何通過Control.BackColor屬性更改控件的背景顏色。那麼,你的問題到底是什麼? – 2010-10-19 18:19:29