Control - Date / Time Picker

images\btn_ctrl_datetime_picker.gif Displays date and/or time info and provides an interface for modifying date and time. Dropdown menu provides a MonthView calendar.

 

The UpDown property sets whether this control operates as a masked edit box for dates and times, or if it operates with a dropdown calendar. Setting UpDown true adds an UpDown control to the box and suppresses the calendar. Using the UpDown button will tab the focus between each part of the date and time mask for entry of that part of the date/time.

 

Properties

 

In addition to the properties listed below, a Control tab provides access to certain frequently used form properties for this control. See the Form Properties topic for information on those properties.

 

 

DateTimePicker

General

 

Value

Date expression that is the default property of the control. Set a default date, if desired.

MinDate

Date expression setting lower boundary of the calendar.

MaxDate

Date expression setting upper boundary of the calendar.

Format

LongDate, ShortDate, Time or Custom.

MousePointer

The type of mouse pointer displayed when over the DateTimePicker. Choose from 16 different types plus a custom pointer

OLEDropMode

Set to None (default) if the DateTimePicker does not accept OLE drops and is to display the No Drop cursor if an OLE drop is attempted. Set to Manual, the DateTimePicker will trigger OLE drop events, allowing programs to handle the OLE drop operation in code.

CustomFormat

string setting forth custom format when Format is set to custom.

Enabled

True or False. True means the object can respond to user-generated events, false prevents it from responding.

CheckBox

False (Default) - Control always returns a date. True - A checkbox appears. If the user does not check this box, no date is returned. Handy for forms where requiring a date ("Due date?") is an option.

UpDown

True - UpDown control appears to change the date instead of a drop down calendar. False (Default) - Calendar appears. When True, switches mode to become a masked edit control.

Time

Sets Hour, Minute and Second properties.

 

 

Font

 

Properties

Font properties that may be changes.

Font

Choose a font installed on this system. It's wise to choose standard Windows fonts such as MS Sans Serif that are universally available.

Size

Size of font, in points. The size of the font sets the size of the drop down portion of this control.

Effects

Bold, Italic, Underline or Strikeout.

Sample Text

A preview of the selected settings.

 

 

Color

 

CalendarBackColor

Color to be used for the DateTimePicker's background.

CalendarForeColor

Color to be used for the DateTimePicker's foreground, the color of the text caption.

CalendarTitleBack Color

Customize calendar title background color.

CalendarTitleFore Color

Customize calendar title foreground color.

CalendarTrailingForeColor

Color of dates that preceded and follow the displayed month or months.

Color Set

Choose from Standard Colors (standard Windows non-dithered colors) or Windows System Colors. The latter will be defined by the user's Control Panel settings and is normally the setting used so that the form changes appearance like the rest of Windows if the Control Panel settings are changed.

Color Palette

Displays available colors. Click on the property to be changed to highlight it in the Properties pane, click on the desired color in the Color Palette pane and then press Apply.

Edit Custom Color

Change the custom color presented in the Color Palette when the Color Set is set to Windows System Colors.

 

 

Picture

 

MouseIcon

Custom icon to use when the MousePointer property is set to 99. Like Visual Basic, will not load animated cursor (.ani) files.

 

Custom Date and Time Formats

 

The CustomFormat property of the DateTimePicker allows specifying fully custom formats for dates and times that can intermingle regular text and the following special format characters within the mast string.

 

d

One- or two-digit day.

dd

Two-digit days with single digits prefixed with 0.

ddd

Three-character abbreviated weekday.

dddd

Full weekday name.

h

One- or two-digit hour in 12-hour format.

hh

Two-digit hour in 12-hour format with single digit hours prefixed with 0.

H

One- or two digit hour in 24-hour format.

HH

Two-digit hour in 24-hour format with single digit hours prefixed with 0.

m

One- or two-digit minute.

mm

Two-digit minutes with single digits prefixed with 0.

M

One- or two-digit month number.

MM

Two-digit month numbers with single digits prefixed with 0.

MMM

Three-character month name abbreviation.

MMMM

Full month name.

s

One- or two-digit second.

ss

Two-digit seconds with single digits prefixed with 0.

t

One-letter AM/PM abbreviation: either "A" or "P"

tt

Either "AM" or "PM"

X

A callback field. The control fills in all other fields and then asks the owner how to fill in the portion with "X" characters. Use different numbers of X's (like, XX or XXXX for different call back fields in the same mask string).

y

The last digit of the year.

yy

The last two digits of the year.

yyy

The full year.

 

Example:

 

"'The date is 'ddddMMMMdd, yyy ' and the time is 'h:mtt"

 

Will result in dates such as:

 

"The date is Friday February 04, 2000 and the time is 3:34 PM"

 

Callbacks are used with format strings like "dddd XX " to see what should be put in the XX based on what is in the dddd, for example to substitute the XX with a non-English day name in addition to the English name. If the dddd is "Wednesday" you could write the appropriate non-English name for the target audience. Consult a good VB reference text for use of callbacks with this control.

 

Notes

 

·      More than one month may be displayed at a time by setting MonthRows and MonthColumns properties at run time.

·      Determine which day of the week appears as the first day at run time by changing the value of the StartOfWeek property.

·      Individual days can have their day number boldfaced at run time to emphasize holidays, etc.