Monday, June 10, 2013

How to create Count Down Timer in C# Windows Application


public int hours = 00;   // Hours.
public int minutes = 10; // Minutes.
public int seconds = 00; // Seconds.

private void timer1_Tick(object sender, EventArgs e)
        {
            if (seconds < 1)
            {
                seconds = 59;
                if (minutes == 0)
                {
                    minutes = 59;
                    if (hours != 0) hours -= 1;
                }
                else
                {
                    minutes -= 1;
                }
            }
            else seconds -= 1;
            lblHr.Text = hours.ToString();
            lblMin.Text = minutes.ToString();
            lblSec.Text = seconds.ToString();
        }

private void CountDownTimer1_Load(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }

4 comments :

  1. thank you dear this is very help full exampl....

    ReplyDelete
  2. thnx for using this blog if any kind of help in c# windows application and asp.net mail me

    ReplyDelete
  3. can u help me on 1 hours countdown in C# windows application

    ReplyDelete