Version

Edit and Display Modes in WebDateTimeEditor

WebDateTimeEditor™ allows you to specify different format strings for when the control is in edit and display modes. You can set the format of the date used for edit mode (i.e. when the control has input focus) by simply setting the control’s EditModeFormat property. Similarly, you can set the format of the date used for display mode (i.e. when the control doesn’t have input focus) by simply setting the control’s DisplayModeFormat property.

Note
Note:

EditModeFormat and DisplayModeFormat properties depend on the System.Globalization.DateTimeFormatInfo class.

You can set the EditModeFormat and DisplayModeFormat properties either by using the Microsoft® Visual Studio® Property Window or by using the following code:

In Visual Basic:

'Create a DateTimeFormatInfo object
Dim format As New System.Globalization.DateTimeFormatInfo()
'Set the EditModeFormat property of WebDateTimeEditor to the pattern you want
WebDateTimeEditor1.EditModeFormat = format.ShortDatePattern
'Set the DisplayModeFormat property of WebDateTimeEditor to the pattern you want
WebDateTimeEditor1.DisplayModeFormat = format.LongDatePattern

In C#:

//Create a DateTimeFormatInfo object
System.Globalization.DateTimeFormatInfo format = new System.Globalization.DateTimeFormatInfo();
//Set the EditModeFormat property of WebDateTimeEditor to the pattern you want
WebDateTimeEditor1.EditModeFormat = format.ShortDatePattern;
//Set the DisplayModeFormat property of WebDateTimeEditor to the pattern you want
WebDateTimeEditor1.DisplayModeFormat = format.LongDatePattern;

EditMode:

WebDateTimeEditor Edit and Display Modes in WebDateTimeEditor 01.png

DisplayMode:

WebDateTimeEditor Edit and Display Modes in WebDateTimeEditor 02.png