using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace 倒计时 { public partial class Form1 : Form { public Form1() { InitializeComponent(); timer1.Interval = 800; } int a = 10; private void button1_Click(object sender, EventArgs e) { if (timer1.Enabled) { timer1.Stop(); button1.Text = "开始"; } else { timer1.Start(); button1.Text = "暂停"; } } private void timer1_Tick(object sender, EventArgs e) { a--; if (a < 4) { label2.ForeColor = Color.Red; } else { label2.ForeColor = Color.Green; } if (a < 0) { timer1.Stop(); button1.Text = "开始"; } else { label2.Text = a.ToString(); } } private void button2_Click(object sender, EventArgs e) { a = 10; label2.Text = a.ToString(); } } }
标签:Text,label2,System,倒计时,button1,timer1,using From: https://www.cnblogs.com/fushuxuan/p/18298590