求高手帮个忙完善下我的电梯,怎么button的颜色在我点下一个的时候按顺序动起来
Button btn = null;private void Form1_Load(object sender, EventArgs e)
{
int k = 30;
for (int i = 0; i< 10; i++)
{
for (int j = 0; j < 3; j++)
{
btn = new Button();
btn.Name = "btn" + k;
btn.Text = "" + k;
k--;
btn.Location = new Point(80 * j, 30 * i);
this.Controls.Add(btn);
btn.BackColor = Color.White;
}
}
foreach (Control c in this.Controls)
{
Button b = c as Button;
b.Click += new EventHandler(b_Click);
}
}
void b_Click(object sender, EventArgs e)
{
Button b = sender as Button;
MessageBox.Show(b.Name);
b.BackColor = Color.Red;
} --------------------编程问答-------------------- 没能理解.. --------------------编程问答-------------------- 你是想跟LED灯似的循环变颜色? --------------------编程问答--------------------
void b_Click(object sender, EventArgs e)
{
Button b = sender as Button;
MessageBox.Show(b.Name);
b.BackColor = Color.Red;
int i = Convert.ToInt32(b.Text);
foreach (Control c in this.Controls)
{
Button button = c as Button;
if (Convert.ToInt32(button.Text) < i)
{
button.BackColor = Color.Red;
}
}
}
补充:.NET技术 , C#