using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{int d=0,c=0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
c=c+1;
button1.Text =c.ToString();
}
private void timer1_Tick(object sender, EventArgs e)
{
c = c + 1;
d=c%3;
if (d==0)
{
button1.BackColor=System.Drawing.Color.FromName("Red");
}
else button1.BackColor = System.Drawing.Color.FromName("white");
if (d == 1)
{
button2.BackColor = System.Drawing.Color.FromName("Black");
}
else button2.BackColor = System.Drawing.Color.FromName("white");
if(d==2)
{
button3.BackColor = System.Drawing.Color.FromName("Green");
}
else button3.BackColor = System.Drawing.Color.FromName("white");
}
}
}
(紅綠燈)
沒有留言:
張貼留言