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 _08 { public partial class Form1 : Form { public Form1() { InitializeComponent(); label2.ForeColor = Color.Black; label2.Text = "" + i; timer1.Interval = 1000; } int i = 10; private void timer1_Tick(object sender, EventArgs e) { if (i <= 4) { label2.ForeColor = Color.Red; } if (i > 0) { i--; label2.Text = "" + i; } } private void button1_Click(object sender, EventArgs e) { if (timer1.Enabled == true) { timer1.Stop(); } else { timer1.Start(); } } private void button2_Click(object sender, EventArgs e) { i = 10; label2.Text = "" + i; timer1.Stop(); } } }
标签:10,Text,label2,System,倒计时,timer1,using From: https://www.cnblogs.com/wangyihang-xh/p/18298512