Skip to main content

DateEdit.EditValue Property

Gets or sets the edit value.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v25.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public override object EditValue { get; set; }

Property Value

Type Description
Object

The edit value.

Remarks

Bind the EditValue property to a DateTime data field in an underlying data source. The following code snippet binds EditValue to the OrderDate field of a BindingSource:

dateEdit1.DataBindings.Add(new System.Windows.Forms.Binding(
    "EditValue", ordersBindingSource, "OrderDate", true));

The DateEdit exposes a set of related properties that define the edit value and the displayed text.

EditValue

The DateEdit.EditValue property stores the current value. The DateEdit control displays this value as text in the edit box.

EditValue updates only when a user selects a single date. EditValue does not change in multi-selection mode.

The DateEdit control fires the following events in response to EditValue changes:

Typing triggers multiple change cycles. Each date segment update raises the event pair:

Edit Value Changed Events - WinForms Date Edit, DevExpress

Set the DateEdit.Properties.EditValueChangedFiringMode property to Buffered to delay events until input completion.

DateTime

The DateEdit.DateTime property specifies a strongly typed DateTime value. It mirrors EditValue and ignores multiple date selection.

Do not bind the DateTime property. Bind EditValue to a data source instead.

DateOnly

The DateEdit.DateOnly property specifies a strongly typed DateOnly value. It mirrors EditValue and ignores multiple date selection.

Do not bind the DateTime property. Bind EditValue to a data source instead.

Text

The DateEdit.Text property gets the text displayed in the edit box. The control converts its EditValue to text with ToString().

Use Format Specifiers, Masks, or handle the FormatEditValue event to modify default formatting settings.

The following code snippet formats the display text as “dd MMMM, yyyy“ (for example, “22 March, 2019“):

using DevExpress.Utils;
using DevExpress.XtraEditors.Controls;

// #1 - Use format specifiers.
dateEdit1.Properties.DisplayFormat.FormatType = FormatType.DateTime;
dateEdit1.Properties.DisplayFormat.FormatString = "dd' 'MMMM', 'yyyy";

// #2 - Use event-based formatting.
dateEdit1.FormatEditValue += DateEdit1_FormatEditValue;

void DateEdit1_FormatEditValue(object sender, 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) {
    }
}

Synchronization

EditValue, DateTime, and DateOnly properties are synchronized. A change in one property updates other properties.

SelectedRanges

The DateEdit.SelectedRanges property stores selected date intervals. Use this property in multi-selection mode.

EditValue, DateTime, and DateOnly properties support single-date selection only. Use SelectedRanges to obtain selected dates when the SelectionMode property is set to Multiple.

The following code snippets (auto-collected from DevExpress Examples) contain references to the EditValue property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also