C#用户在文本框中输入倒计时的分钟数,点击“重新开始”按钮开始倒计时。(
1个回答
展开全部
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--;
}
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--;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询