Timers

Oct 11 2010 3:41 PM
sir,

          I have a query here, I want the start and stop to be the same button and  I want to display the time that tells me how many seconds it took me to start and stop. I am unable to do that seeking your help. here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Timers4
{
    public partial class TimingGameForm : Form
    {
        public TimingGameForm()
        {
            InitializeComponent();
        }
        private int elapsed = 0;
        private bool started = false;
       
        private void Start_Click(object sender, EventArgs e)
        {
            if (started == true)
            {
                timer1.Enabled = true;
                Estimatelbl.Text = "Running....";
                
            }
            else if (started == false)
            {
                timer1.Enabled = false;
                Timelbl.Text = "that took" + elapsed + "seconds";
                
            }
            

        }
          private void timer_Tick(object sender, EventArgs e)
          {
              elapsed += 1;     
              
   
                
             
          }

      }
}

Answers (2)