Windows Forms: Digital Clock in C#

How to Create a Digital Clock using Circular ProgressBar in C#

Step 1Click New Project, then select Visual C# on the left, then Windows and then select Windows Forms Application. Name your project "AppClock" and then click OK

digital clockStep 2: Right click on your project select Manage NuGet Packages -> Search CircularProgressBar -> install

install circular propressbar

Step 3: Design your form as below

digital clock

You should add a timer control to your form

Step 4: Add code to Form_Load event

private void Form1_Load(object sender, EventArgs e)
{
    System.Timers.Timer timer = new System.Timers.Timer();
    timer.Interval = 1000;//1s
    timer.Elapsed += Timer_Elapsed;
    timer.Start();
}

Add code to Timer_Elapsed event

private void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
    //Invoke an anonymous method on the thread of the form.
    circularProgressBar1.Invoke((MethodInvoker)delegate
    {
        //Set time to circular progressbar
        circularProgressBar1.Text = DateTime.Now.ToString("hh:mm:ss");
        circularProgressBar1.SubscriptText = DateTime.Now.ToString("tt");//AM or PM
    });
}

VIDEO TUTORIALS