Visual Basic: Windows Controls

DateTimePicker Control

See Also   Example   Properties   Methods   Events

The DateTimePicker control enables you to provide a formatted date field that allows easy date selection. In addition, users can select a date from a dropdown calendar interface similar to the MonthView control.

Syntax

DTPicker

Remarks

The DateTimePicker control, operates in two modes:

  • Dropdown Calendar mode (default) enables the user to display a dropdown calendar that can be used to select a date.

  • Time Format mode enables the user to select a field in the date display (i.e. the month, day, year, etc.) and press the up/down arrow to the right of the control to set its value.

You can customize the appearance of the drop-down calendar of the control. Various color attributes such as CalendarBackColor, CalendarForeColor, CalendarTitleBackColor, CalendarTitleForeColor and CalendarTrailingForeColor enable you to create a unique color scheme.

The control can be navigated using either the keyboard or mouse. The drop-down calendar has two buttons that enable you to scroll months in and out of view.

Note   The DateTimePicker control is part of a group of ActiveX controls that are found in the MSCOMCT2.OCX  file. To use the DateTimePicker control in your application, you must add the MSCOMCT2.OCX  file to the project. When distributing your application, install the MSCOMCT2.OCX  file in the user's Microsoft Windows System or System32 directory. For more information on how to add an ActiveX control to a project, see "Adding Controls to a Project" in the Programmer's Guide.