Getting Started with Windows Forms Clock
29 May 20234 minutes to read
This section provides a quick overview for working with the Clock control for WinForms.
Assembly deployment
Refer to the Control dependencies section to get the list of assemblies or details of NuGet package that needs to be added as a reference to use the control in any application.
Click NuGet Packages to learn how to install nuget packages in a Windows Forms application.
Creating Application with Clock
In this walk through, users will create WinForms application that contains Clock control.
Creating the Project
Create new Windows Forms Project in Visual Studio to display Clock with data objects.
Adding Clock control via designer
-
Create a new Windows Forms project in Visual Studio.
-
The Clock control can be added to an application by dragging it from the toolbox to a designer view. The following dependent assemblies will be added automatically:
- Syncfusion.Grid.Base
- Syncfusion.Grid.Windows
- Syncfusion.Shared.Base
- Syncfusion.Shared.Windows
- Syncfusion.Tools.Base
- Syncfusion.Tools.Windows
Adding Clock control via code
To add the control manually in C#, follow the given steps:
-
Create a C# or VB application via Visual Studio.
-
Add the following assembly references to the project:
- Syncfusion.Grid.Base
- Syncfusion.Grid.Windows
- Syncfusion.Shared.Base
- Syncfusion.Shared.Windows
- Syncfusion.Tools.Base
- Syncfusion.Tools.Windows
-
Include the required namespace.
using Syncfusion.Windows.Forms.Tools;
Imports Syncfusion.Windows.Forms.Tools
-
Create an instance of the Clock control instance, and add it to the form.
Clock clock1 = new Clock(); this.Controls.Add(clock1);
Dim clock1 As New Clock() Me.Controls.Add(clock1)
Clock type
You can change the analog clock to digital clock by setting the ClockType property of the Clock control.
clock1.ClockType = Syncfusion.Windows.Forms.Tools.ClockTypes.Digital;
clock1.ClockType = Syncfusion.Windows.Forms.Tools.ClockTypes.Digital
For Analog Clock,
clock1.ClockType = Syncfusion.Windows.Forms.Tools.ClockTypes.Analog;
clock1.ClockType = Syncfusion.Windows.Forms.Tools.ClockTypes.Analog
Change date and time
To enable custom time, the Clock control should be enabled by setting the ShowCustomTimeClock property to true
, and the custom time should be in date-time format.
clock1.ShowCustomTimeClock = true;
clock1.CustomTime = new System.DateTime(2019, 7, 3, 16, 50, 1, 0);
clock1.ShowCustomTimeClock = True
clock1.CustomTime = New System.DateTime(2019, 7, 3, 16, 50, 1, 0)