C#怎么用Timer做一个30秒倒计时小程序

2024-11-19 15:23:04
推荐回答(2个)
回答1:

public partial class Form1 : Form
{
int count = 30;
public Form1()
{
InitializeComponent();
textBox1.Text = count.ToString();
timer1.Start();
}

private void timer1_Tick(object sender, EventArgs e)
{
if (--count == 0)
count = 30;
textBox1.Text = count.ToString();
}
}

回答2:

在timer时间里面加入Application.DoEvent()