public partial class Form1 : Form
{
int c = 0,d=0;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
c = c + 1;
}
private void timer1_Tick(object sender, EventArgs e)
{
c = c + 1;
d = c % 3;
if (d == 2)
{
button1.BackColor = Color.Black;
button3.BackColor = Color.Black;
button4.BackColor = Color.Red;
}
else if (d == 1)
{
button1.BackColor = Color.Black;
button3.BackColor = Color.Yellow;
button4.BackColor = Color.Black;
}
else
{
button1.BackColor = Color.Green;
button3.BackColor = Color.Black;
button4.BackColor = Color.Black;
}
}
}
}
沒有留言:
張貼留言