Hello, I have created a timer for my Winforms to tick down from 300 to 0 and then refresh my form. I have used this.refresh when it hits 0 but it doesn't seem to do anything as the label is still the same when it has completed it's timer function. Any ideas how to get it to work?

// Start the timer.
            timeLeft = 300;            

 private void timer1_Tick(object sender, EventArgs e)
            if (timeLeft > 0)
                timeLeft = timeLeft - 1;
                lblTime.Text = timeLeft + " seconds";
            else if (timeLeft == 0)
                //Timer runs out of time and refresh form

Please use code tags if you post code.
What label are you talking about?
else if (timeLeft == 0) is a bit meaningless, you can just as well say else


I have come up with a solution but not sure if it is sound coding but it works.. I have put TimeLeft = 300 again, when the timer hits 0 so it goes back to 300.

This question has already been answered. Start a new discussion instead.