Skip to main content

DateEdit Class

The editor with a dropdown calendar used to display and edit date/time values.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[DefaultBindingPropertyEx("DateTime")]
public class DateEdit :
    PopupBaseEdit,
    IDateRangeCollectionOwner

Remarks

The DateEdit control allows you to display and edit date/time values. Users can type within the edit box or select the date from the dropdown calendar.

DateEdit-class

Run Demo

Edit Value

Use the DateTime, DateOnly, or EditValue property to specify the editor’s value.

Calendar Views and Styles

Use the Properties.CalendarView property to specify a calendar view/style. Available views include:

Calendar Style Description
Fluent

The calendar that supports the Acrylic and Reveal Highlight effects and allows you to mirror the appearance of the Windows 10 calendar.

Vista Vista-style Calendar
TouchUI

The touch-aware date-editing UI:

   

For a DateEdit control, the control’s mask (see the RepositoryItemTextEdit.Mask inherited property) specifies which date-time columns are displayed in the dropdown calendar.

To display time columns, enable the RepositoryItemDateEdit.CalendarTimeEditing option.

Classic

The classic calendar:

   

ClassicNew

An Outlook 2016-inspired calendar style.

   

In Vista view, use the VistaCalendarViewStyle property to specify which date-grouping views are available to users.

dateEdit1.Properties.Mask.EditMask = "Y";
dateEdit1.Properties.Mask.UseMaskAsDisplayFormat = true;
dateEdit1.Properties.VistaCalendarViewStyle = DevExpress.XtraEditors.VistaCalendarViewStyle.YearView;

Vista Calendar View Style - WinForms DateEdit, DevExpress

Main Settings and Events

Use the DateEdit.Properties property to customize DateEdit specific settings.

DateEdit-class

General settings include:

Masked Input

By default, DateEdit functions in DateTime masked mode; this allows you to enter date/time values using one of the standard or custom date/time patterns. Use the RepositoryItemDateEdit.EditMask property to switch from the default pattern (short date -“d”) to another one.

Set the MaskProperties.MaskType (DateEdit.Properties.Mask.MaskType) property to DateTimeAdvancingCaret to allow the caret to automatically skip date separators while entering date/time values.

Note

The date/time masks only support the following calendars: Gregorian, Korean, Taiwan, and Thai Buddhist.

Date Range Selection

Set the SelectionMode property to CalendarSelectionMode.Multiple to allow users to select multiple dates. Use the SelectedRanges property to obtain the selected date range.

Date Range Selection - WinForms Date Editor, DevExpress

dateEditSample.Properties.SelectionMode = DevExpress.XtraEditors.CalendarSelectionMode.Multiple;
DateRangeCollection selectedDates = dateEditSample.SelectedRanges;

Bind to Data Source

If you need to bind the DateEdit control to a field in an underlying data source/business object, we recommend that this field stores date/time values.

If the DateEdit is bound to a string field, the editor value is updated according to current culture. For instance, day and month date portions can swap places. In this case, you need to manually parse editor values:

var date = DateTime.Parse("11-07-2020", CultureInfo.InvariantCulture);

Enter Date-Time Values

See the following topic to learn about editors you can use to enter date-time values: How to: Enter date-time values.

Inheritance

See Also