用c#做点击按钮后实现开始倒计时,点击按钮后再实现关闭倒计时
2个回答
展开全部
int lefttime;
private void button1_Click(object sender, EventArgs e)
{
int minute;
try
{
minute = int.Parse(this.textBox1.Text);
}
catch (System.Exception ex)
{
this.label1.Text = "输入错误";
return;
}
lefttime = minute * 60;
this.timer1.Interval = 1000;
this.timer1.Enabled=true;
this.timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
this.label1.Text = "剩余时间" + lefttime.ToString()+"秒";
lefttime--;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询