Designing A Digital Clock Using Windows Form In Visual Studio

In this article, I will tell you how to design a Digital clock in Visual Studio 2017.


In this article, I am going to explain how to build a simple digital clock in C# using Visual Studio 2017. Some of the applications need to include a digital clock. Designing a digital clock is simple and you can enhance and upgrade as you like. You can also use this digital clock in your application.

Follow the below steps to build a digital clock.

Step 1

Open Visual Studio 2017--->New Project ---->Windows Forms Project and name it as Digital Clock.
Windows Forms
Step 2

A blank form is opened. Now, design the form as shown in the screenshot given below. Drag and drop the label from the Toolbox to the form. Right-click on the Label and select Properties. Here, you can change font color and the name of the Label etc.

Function of Label Control

Windows.Forms Label control is used to display the text or images that cannot be edited by the user.

Windows Forms
Step 3

Now, drag and drop timer from the toolbox to the form. The Timer control starts its functionality only after its enabled property is said to be true. By default, Enabled Property is False. When you use this timer, the following changes should be made whenever the enabled property is said to true and the interval property should be greater than zero. The tick event is raised at intervals based on interval property setting.

Function of Timer Control

Timer controls play an important role in the client-side programming. The server-side programming is also used in Windows Services.

Windows Forms
Step 4

Now, it's time to code but before that, change the Tick property of the Timer. Write the code in the timer function as given below in the screenshot.

Here, I set the Label as Label1. Now, write this code in the Timer function.
Windows Forms

Run the program. Now, your clock looks like the given below.

Windows Forms 
Step 5

Add am/pm in your digital clock by following the simple step. Now, write this code in Timer function.

Windows Forms

Run the program. Now, your clock looks like as given below in the screenshot.

Windows Forms

Now, you have learned to create a Digital Clock in C#. In case of any doubts or error from this project, feel free to comment it down. I can help you to solve the problem.