DateTimePicker Control

DateTimePicker Control : (Pickers)

The DateTimePicker control displays a graphical calendar from which users can select a date required by them. It also displays date & time with a specified format.

If you click the drop down arrow of the date-time picker, it displays a month calendar. Use of the DateTimePicker control eliminates the need for validating date/time values.

Property :

1. MaxDate : Gets or sets the maximum date and time that can be selected in the control.

2. MinDate : Gets or sets the minimum date and time that can be selected in the control.

3. Format : Gets or sets the format of the date and time displayed in the control. It can be custom or long or short or time.

To display only time in a DateTimePicker, set the Format property to Time, and to view up down button set the ShowUpDown property to true. 

Custom :   You can create your own format style by setting the Custom Format property. 

LongDisplays the date/time value in the long date format set by the user’s operating system. 
Short  Displays the date/time value in the short date format set by the user’s operating system. 
TimeThe DateTimePicker control displays the date/time value in the time format set by the user’s operating system.

4. CustomForamt : It is used to specify custom date/time format string. For example dd/MM/yyyy

image 8
  1. d  – The one-or-two digit day.
  2. dd  – The two-digit day. Single-digit day values are preceded by a zero,
  3. ddd – Three characters day-of-week abbreviation.
  4. dddd – The full day-of-week name.
  5. h – The one or a two-digit hour in 12-hour format.
  6. hh –  The two-digit hour in 12-hour format. Single-digit day values are preceded by a zero,
  7. H – The one or a two-digit hour in 24-hour format.
  8. HH – The two-digit hour in 24-hour format. Single-digit day values are preceded by a zero,
  9. MMM – The three-character month abbreviation.    …….Etc….

5. ShowUpDown : Gets or sets a value indicating whether a spin button control (also known as an updown control) is used to adjust the date/time value.

Events :

  1. DropDown : Occurs when the drop-down calendar appears (shown).
  2. CloseUp : Occurs when the drop-down calendar disappears. 
  3. ValueChanged : It Occurs when the Value property changes. 
  4. FormatChanged : It Occurs when the Format property value has changed.

Leave a Comment