我窗体有18个按钮,名字是button1....button18
我想循环着将他们颜色更改为绿色。。。怎么搞。。。
------解决方案--------------------------------------------------------
for (int i = 1; i < 9; i++)
{
Button btn = this.Controls["Button" + i.ToString()] as Button;
btn.ForeColor = Color.Green;
}
for (int i = 1; i < 9; i++)
{
Button btn = this.Controls["Button" + i.ToString()] as Button;
btn.ForeColor = Color.Green;
}