Skip to main content
All docs
V24.1

DateEdit.DateOnly Property

Gets or sets the DateOnly value in the control.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[Bindable(false)]
[DXCategory("Appearance")]
public DateOnly DateOnly { get; set; }

Property Value

Type Description
DateOnly

The selected DateOnly value.

Remarks

You can use the RepositoryItemDateEdit.MinDate and RepositoryItemDateEdit.MaxDate properties to specify the minimum/maximum allowed date.

The DateEdit control has the following interconnected properties that specify what value the editor stores and what text it shows to users at runtime.

Text

(the DateEdit.Text property)

A string value that is the text displayed inside the editor’s text box. Normally, this is the editor’s edit value converted to text with the ToString() method. To modify this text, use Format Specifiers and Masks, or handle the BaseEdit.FormatEditValue event.

The code sample below illustrates two ways to make the DateEdit display its text in the “dd MMMM, yyyy” format (e.g., “22 March, 2019”).

dateEdit1.Properties.DisplayFormat.FormatType = DevExpress.Utils.FormatType.DateTime;
dateEdit1.Properties.DisplayFormat.FormatString = "dd' 'MMMM', 'yyyy";

//or

dateEdit1.FormatEditValue += DateEdit1_FormatEditValue;
private void DateEdit1_FormatEditValue(object sender, DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs e) {
    try {
        string day = ((DateTime)e.Value).Day.ToString();
        string month = ((DateTime)e.Value).ToString("MMMM");
        string year = ((DateTime)e.Value).Year.ToString();
        e.Value = day + " " + month + ", " + year;
        e.Handled = true;
    }
    catch (Exception) {
    }
}

Edit Value

(the DateEdit.EditValue property)

The value stored within the editor. Specifies the currently selected date. The editor’s text box shows the textual representation of this value.

Edit value changes only when a user selects a single date. When users select time intervals that include multiple days (see the RepositoryItemDateEdit.SelectionMode property), the edit value does not update.

When the edit value is about to change, the cancelable DateEdit.EditValueChanging event fires. If it was not cancelled and the new edit value is accepted, the DateEdit.EditValueChanged occurs afterwards. When users type text in the editor’s text box, these events fire when the focus moves from one date “portion” to another. For example, the animation below illustrates that the Changing\Changed event pair fires three times when a user edits “MM/DD/YYYY”-formatted dates.

image

You can set the DateEdit.Properties.EditValueChangedFiringMode property to Buffered to force the Changing\Changed events to fire when a user stops typing text, before they move focus to another date “portion”.

Date Time

(the DateEdit.DateTime property)

Similar to the Edit Value, stores the currently selected date and does not change when users select multiple time intervals. Returns a DateTime structure instead of an Object.

This property cannot be bound to a data source field. If you need the editor to display values from a data source, bind the EditValue property instead.

EditValue, DateTime, and DateOnly properties are synced: when either of them changes, the other property is updated as well.

Date Only

(the DateEdit.DateOnly property)

Similar to the Date Time, stores the currently selected date and does not change when users select multiple time intervals. Returns a DateOnly structure.

This property cannot be bound to a data source field. If you need the editor to display values from a data source, bind the EditValue property instead.

EditValue, DateTime, and DateOnly properties are synced: when either of them changes, the other property is updated as well.

Selected Ranges

(the DateEdit.SelectedRanges property)

Stores selected date intervals. Since EditValue, DateTime, and DateOnly properties store only single-date selection values, use this collection to get or set selected DateTime values when the RepositoryItemDateEdit.SelectionMode property is set to Multiple.

See Also