How to make a clock with a timer

The simplest method to make a Clock in C # is to use a timer. In this article, we will show you how to make a clock with a timer. We developed our project with Visual Studio 2010.

First, we create a new project and add it by dragging the Timer component from our toolbox menu.

 

then we make the interval feature of the timer component 1000 so that we can update one hour every second. In order to reach the properties of the timer object, when we right click on the timer component we drag into the form, we select properties from the menu that appears. When we first start the program, we set the Enabled property to True.

Then we add labels on the form from the toolbox menu. and double click on the Tick event of the Timer component and add the code below.

private void timer1_Tick(object sender, EventArgs e)
{
     label1.Text = DateTime.Now.ToLongTimeString();
}

 

Finally, we make the label properties 40 of the field from the font properties.

 

click to download

 

Tagged In:

Software developer

26 Total Posts