Seconds CountDown Timer

后端 未结 5 1047
花落未央
花落未央 2020-12-03 11:14

I have a lblCountdown with an int value of 60. I want to make the int value of the lblCountDown decrease with seconds until it reaches 0.

This is what I have so far:

5条回答
  •  无人及你
    2020-12-03 11:57

    Hey please add code in your project,it is easy and i think will solve your problem.

        int count = 10;
    
        private void timer1_Tick(object sender, EventArgs e)
        {
            count--;
            if (count != 0 && count > 0)
            {
                label1.Text = count / 60 + ":" + ((count % 60) >= 10 ? (count % 60).ToString() : "0" + (count % 60));
            }
            else
            {
                label1.Text = "game over";
    
            }
    
        }
    
        private void Form1_Load(object sender, EventArgs e)
        {
            timer1 = new System.Windows.Forms.Timer();
            timer1.Interval = 1;
    
            timer1.Tick += new EventHandler(timer1_Tick);
    
        }
    

提交回复
热议问题