Skip to main content

CalendarControlBase.FormatEditValue Event

Allows you to convert the EditValue to the DateTime format.

Namespace: DevExpress.XtraEditors.Controls

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[DXCategory("Events")]
public event ConvertEditValueEventHandler FormatEditValue

Event Data

The FormatEditValue event's data class is ConvertEditValueEventArgs. The following properties provide information specific to this event:

Property Description
Handled Gets or sets a value specifying whether default edit value conversion/formatting is required.
Value Gets or sets either the edit or the display value of an editor.

Remarks

You specify the selected date for the calendar using the CalendarControlBase.EditValue property. This property is of the Object type, and accepts values of any type. When a value about to be assigned to this property, the CalendarControlBase.ParseEditValue event fires, allowing you to parse the value being assigned, and perform required actions. For instance, if the value is a string in the YYYY-MM-DD format, you can change hyphens to slashes or dots. The parsed value is then assigned to the CalendarControlBase.EditValue property.

The CalendarControlBase.DateTime property, which is of the DateTime type, returns the CalendarControlBase.EditValue converted (formatted) to the DateTime type. The conversion is performed as follows. If the CalendarControlBase.EditValue is not of the DateTime type, the FormatEditValue event fires, allowing you to convert the value to the DateTime type. To do this, set the Handled event argument to true, and provide a valid date using the Value argument. If the event is not handled, the CalendarControlBase.DateTime property returns the CalendarControlBase.NullDate property value. If the CalendarControlBase.NullDate property is not specified, the smallest possible date is returned.

Note

The FormatEditValue event may be called multiple times consecutively. The number of calls is different for different editor types and it may also depend on the editor usage (standalone or embedded).

See Formatting to learn more.

See Also