Javatpoint Logo
Javatpoint Logo

VB.NET DateTimePicker Control

The DateTimePicker control allows the user to select or display date and time values with a specified format in Windows Forms. Furthermore, we can determine the current date and time using the Value property of the DateTimePicker control. By default, the Value property returns the current date and time in the DateTimePicker.

Let's create a DateTimePicker control in the VB.NET Windows form using the following steps.

Step 1: The first step is to drag the DateTimePicker control from the toolbox and drop it on to the form.

VB.NET DateTimePicker Control

Step 2: Once the DateTimePicker is added to the form, we can set various properties of the DateTimePicker by clicking on the DateTimePicker control.

Note: The MinDate and MaxDate property of the DateTimePicker control allows the user to set the limits on the date range.

Properties of the DateTimePicker Control

There are some properties of the VB.NET DateTimePicker control.

Property Description
BackgroundImage It is used to set the background image for the DateTimePicker control.
CalendarFont It is used to set the font style for the calendar in the DateTimePicker control.
CustomFormat The CustomFormat property is used to set the custom date and time format string in the DateTimePicker control.
Controls It is used to obtain the collection of controls that are stored within the DateTimePicker control.
Checked A checked property is used to check whether the value property is checked with a valid date and time in the DateTimePicker control.
Format The Format property of the DateTimePicker is used to set the format for the Date and time displayed in the Windows Form.
MaxDate The MaxDate property of the DateTimePicker is used to set the max data and time in control selected by the user.
Name The Name property of the DateTimePicker control allows the user to set the name of the control.
MinimumDateTime It is used to set the minimum date value that can be allowed by control.

Methods of the DateTimePicker Control

There are some Methods of the VB.NET DateTimePicker control.

Method Description
Contains(Control) It is used to validate whether the specified control is a child of the DateTimePicker control or not.
CreateControl() It is used to force the creation of visible control to handle the creation and any visible child controls.
GetAutoSizeMode() The GetAutoSizeMode() method is used to check the behavior of the DateTimePicker control when the AutoAize property is enabled.
ResetBackColor() It is used to reset the back color of the DateTimePicker control.
Select() The Select() method is used to start or activate the DateTimePicker control.
Show() The Show() method is used to display the control to the user.
ToString() The ToString() method is used to return a string that represents the current DateTimePicker control.

Furthermore, we can also refer to VB.NET Microsoft documentation to get a complete list of DateTimePicker control properties, and methods in the VB.NET.

Let's create a program of DateTimePicker control in the VB.NET form.

DateTime.vb

Output:

VB.NET DateTimePicker Control

Now, we select the date of birth from the DateTimePicker Control.

VB.NET DateTimePicker Control

After selecting the DOB and the Current date from the DateTimePicker Control, now click on the Calculate button, and it shows the following result.

VB.NET DateTimePicker Control
Next TopicTreeView Control




Youtube For Videos Join Our Youtube Channel: Join Now

Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA