namespace WindowsFormsdingshiqi
{ public partial class Form1 : Form { int time; int count; public Form1() { InitializeComponent(); } // private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) // { // } private void Form1_Load(object sender, EventArgs e) { int i ; for (i = 1; i < 100; i++) { comboBox1.Items.Add(i.ToString() + " 秒"); } } private void timer1_Tick(object sender, EventArgs e) { count++; label3.Text = (time - count).ToString()+“秒”; progressBar1.Value = count; if (count == time) { timer1.Stop(); MessageBox.Show(“时间到”); count = 0; } } private void button1_Click(object sender, EventArgs e) { string x; x = comboBox1.Text; time =Convert.ToInt16(x.Substring(0,2)); progressBar1.Maximum = time; timer1.Start(); } }}
一个倒计时的程序源码
希望能帮到需要的人。大佬勿喷。