R
Robert Mayer
Hello!
I would like to count 15 Minutes (in this style: 15:00, 14:59, 14:58 ...)
backwards with a Timer and want to show it on a Label.
The Time is displayed correctly (15:00), but nothing happen.
Did I forgot something??
int Minutes = 15;
int Seconds = 0;
private TimeSpan _tsCountDownTime;
private void timer1_Tick(object sender, System.EventArgs e)
{
TimeSpan tsSecond = new TimeSpan(0,0,1);
_tsCountDownTime.Subtract(tsSecond);
lblCount.Text = _tsCountDownTime.Minutes.ToString() + ":" +
_tsCountDownTime.Seconds.ToString();
}
private void btnStart_Click(object sender, System.EventArgs e)
{
setCountDown(Minutes, Seconds);
tmrCount.Enabled = true;
tmrCount.Start();
}
private void setCountDown(int iMinutes, int iSeconds)
{
TimeSpan tsTemp = new TimeSpan(0, iMinutes, iSeconds);
_tsCountDownTime = tsTemp;
}
Thank you!
I would like to count 15 Minutes (in this style: 15:00, 14:59, 14:58 ...)
backwards with a Timer and want to show it on a Label.
The Time is displayed correctly (15:00), but nothing happen.
Did I forgot something??
int Minutes = 15;
int Seconds = 0;
private TimeSpan _tsCountDownTime;
private void timer1_Tick(object sender, System.EventArgs e)
{
TimeSpan tsSecond = new TimeSpan(0,0,1);
_tsCountDownTime.Subtract(tsSecond);
lblCount.Text = _tsCountDownTime.Minutes.ToString() + ":" +
_tsCountDownTime.Seconds.ToString();
}
private void btnStart_Click(object sender, System.EventArgs e)
{
setCountDown(Minutes, Seconds);
tmrCount.Enabled = true;
tmrCount.Start();
}
private void setCountDown(int iMinutes, int iSeconds)
{
TimeSpan tsTemp = new TimeSpan(0, iMinutes, iSeconds);
_tsCountDownTime = tsTemp;
}
Thank you!