VR Indian Wanderers Youtube RSS Feed
Learn with Vikas Suhag
Design an application that uses the concept of User Control (Stop Watch)
Nov 16, 2021   Vikas Suhag

Stopwatch in C#.Net

AIM : Design an application that uses the concept of User Control (Stop Watch).

Source Code :

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Drawing;

using System.Data;

using System.Linq;

using System.Text;

using System.Windows.Forms;

 

namespace nit

{

    public partial class UserControl1 : UserControl

    {

        int hr, min, sec;

        public UserControl1()

        {

            InitializeComponent();

        }

 

        private void button1_Click(object sender, EventArgs e)

        {

            timer1.Start();

            timer1.Interval = 1000;

           

 

        }

 

        private void timer1_Tick(object sender, EventArgs e)

        {

           

            sec++;

            if (sec == 60)

            {

                min++;

                sec = 0;

            }

 

            if (min == 60)

            {

                hr++;

                min = 0;

            }

            label1.Text = hr.ToString();

            label2.Text = min.ToString();

            label3.Text = sec.ToString();

 

        }

 

        private void button2_Click(object sender, EventArgs e)

        {

            timer1.Stop();

 

        }

        private void button3_Click(object sender, EventArgs e)

        {

            timer1.Stop();

            hr = 0;

           min = 0;

           sec = 0;

           label1.Text = hr.ToString();

           label2.Text = min.ToString();

           label3.Text = sec.ToString();

        }

    }

}

Output:

 


Leave a Comment

* Email will not be published.
All comments are only visible after approval.
Most Viewed articles
Travel Blog - VR Indian Wanderers
VR Indian Wanderers
Govt. Jobs Portal
Govt. Jobs Portal
Free Chart Maker
Make free animated Charts from .CSV
Search
Youtube Channel
Podcast
Subscribe to Email Updates
Connect With Us
VR Indian Wanderers Youtube RSS Feed
© 2024 Learn with Vikas Suhag. All Rights Reserved.