title: Timer Countdown with progress bar C#
body: <p>I want to sync my progress bar in my project with the timer countdown.</p>
  
  <p>This is what I has now:</p>
  
  <pre><code>namespace Timer1
  {
      public partial class Form1 : Form
      {
          public Form1()
          {
              InitializeComponent();
          }
  
          private int counter=80;
          DateTime dt = new DateTime();
          private void button1_Click(object sender, EventArgs e)
          {
              int counter = 80;
              timer1 = new System.Windows.Forms.Timer();
              timer1.Tick += new EventHandler(timer1_Tick);
              timer1.Interval = 1000;
              timer1.Start();
              textBox1.Text = counter.ToString();
          }
  
  
          private void timer1_Tick(object sender, EventArgs e)
          {
              counter--;
              progressBar1.Increment(1);
              if (counter == 0)
              {
                  timer1.Stop();
              }
              textBox1.Text = dt.AddSeconds(counter).ToString("mm:ss");
          }
  
          private void Form1_Load(object sender, EventArgs e)
          {
              timer1.Enabled = false;
          }
  
          private void button2_Click(object sender, EventArgs e)
          {
              timer1.Stop();
              textBox1.Clear();
              progressBar1.Value = 0;
          }
      }
  }
  </code></pre>
  
  <p>I want the progress bar to finish when the timer to ends.</p>
  
  <p><a href="https://i.stack.imgur.com/hzDAJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hzDAJ.jpg" alt="enter image description here"></a></p>