Datetimepicker Control in VB.NET



DateTimePicker Control allows user to select a date and a time. It is also used to display selected date and time in specific format.
DateTime
By default it displays current date in Long Date format. When user clicks on arrow button it displays full calendar for the current month as shown below:

Properties of Datetimepicker Control in VB.NET



Property Purpose

Format

It is used to get or set format for displaying date and time in DateTimePicker Control. It has four options: Long, Short, Time, And Custom. Default format is long.

CustomFormat

It is used to get or set custom format for displaying date and time in DateTimePicker Control.

For Example:

dd/MM/yyyy will display 01/01/2014

d/M/yyyy will display 1/1/2014

d/M/yy will display 1/1/14

ddd, MMM, yyyy will display Wed, Jan, 2013

dddd, MMMM, yyyy will display

Wednesday, January, 2014

hh:mm:ss will display 02:25:02

HH:mm:ss will display 14:25:02

hh:mm:ss tt will display 02:25:02 PM

Value

It is used to get date and time selected in DateTimePicker Control.

ShowCheckBox

It is used to specify weather CheckBox is displayed in DateTimePicker or not. It has Boolean value. Default value is false.

Checked

It is used to specify weather CheckBox in DateTimePicker is checked or not. It has Boolean value. Default value is true. It works only when ShowCheckBox property is set to true.

     

ShowUpDown

It is used to specify weather UpDown arrow is displayed in the DateTimePicker instead of DropDown Calendar or Not. It has Boolean value. Default value is false.

MinDate

It is used to get or set Minimum Date that can be selected using DateTimePicker Control. Default value is 01/01/1753.

MaxDate

It is used to get or set Maximum Date that can be selected using DateTimePicker Control. Default value is 31/12/9998.

Enabled

It is used to specify weather DateTimePicker Control is enabled or not at runtime. It has Boolean value. Default value is true.

Visible

It is used to specify weather DateTimePicker Control is visible or not at runtime. It has Boolean value. Default value is true.

CalendarFont

It is used to get or set Font of the Calendar.

CalendarForeColor

It is used to get or set ForeColor of the calendar font.

CalendarMonthBackground

It is used to get or set Background Color of the Calendar.

CalendarTitleBackColor

It is used to get or set Background Color of Calendar’s Title.

CalendarTitleForeColor

It is used to get or set ForeColor of the font that is displayed in Calendar’s Title.

CalendarTrailingForeColor

It is used to get or set Fore Color of the previous and next month’s date that is displayed in Current Month’s Calendar.


Methods of Datetimepicker Control in VB.NET



Method Purpose

Show

It is used to show DateTimePicker Control at run time.

Hide

It is used to Hide DateTimePicker Control at run time.

Focus

It is used to set cursor or focus on DateTimePicker Control.


Events of Datetimepicker Control in VB.NET



Event Purpose

ValueChanged

It is the default event of DateTimePicker Control. This event fires each time a value in the DateTimePicker Control is changed.

TextChanged

This event fires each time a text that is displayed in the DateTimePicker Control is changed.

CloseUp

This event fires each time a Popup Calendar is disappeared after selecting particular date.

DropDown

This event fires each time a Popup Calendar is displayed by clicking on DropDown arrow.


Download Projects


Download Programs