Seconds CountDown Timer

后端 未结 5 1023
花落未央
花落未央 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

    You need a public class for Form1 to initialize.

    See this code:

    namespace TimerApp
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private int counter = 60;
            private void button1_Click(object sender, EventArgs e)
            {
                //Insert your code from before
            }
    
            private void timer1_Tick(object sender, EventArgs e)
            {
                //Again insert your code
            }
        }
    }
    

    I've tried this and it all worked fine

    If you need anymore help feel free to comment :)

提交回复
热议问题