我正在使用下面的代码以hh:mm:ss
格式显示剩余时间,例如,如果持续时间是30min
,它将显示为这样00:30:00
,1 分钟后将显示00:29:00
,我怎样才能显示剩余的秒数并相应地减少它们。,
编辑
我试过timer1.Interval = 1000;
了
examTime = examTime.Subtract(TimeSpan.FromSeconds(1));
但是它没有显示我每秒减少的秒数,我该怎么做?
public SubjectExamStart()
{
InitializeComponent();
examTime = TimeSpan.FromMinutes(double.Parse(conf[1]));
label1.Text = examTime.ToString();
timer1.Interval = 60 * 1000;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
if (sender == timer1)
{
if (examTime.TotalMinutes > 0)
{
examTime = examTime.Subtract(TimeSpan.FromMinutes(1));
label1.Text = examTime.ToString();
}
else
{
timer1.Stop();
MessageBox.Show("Exam Time is Finished");
}
}
}