RepositoryItem.DisplayFormat Property

Provides access to the format settings applied to the editor's display text. These settings are in effect when the editor does not have input focus.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v20.1.dll

Declaration

[DXCategory("Format")]
public virtual FormatInfo DisplayFormat { get; }
<DXCategory("Format")>
Public Overridable ReadOnly Property DisplayFormat As FormatInfo

Property Value

Type Description
FormatInfo

A FormatInfo object containing the formatting settings applied to the control's display text.

Remarks

Entering date-time and numeric values

See the following topics to learn about the editors you can use to enter date-time and numeric values:

Format values in display mode

The DisplayFormat object of the FormatType class contains properties to format the editor's values in display mode (when the editor doesn't have input focus). Specify the format type (Numeric, DateTime or Custom) with the FormatInfo.FormatType property, set the format pattern (FormatInfo.FormatString) or assign a custom formatter object (FormatInfo.Format).

The following code formats a CalcEdit control's values as currency in display mode.

CalcEdit-DisplayFormat-example

calcEdit1.EditValue = 31.415m;
calcEdit1.Properties.DisplayFormat.FormatType = FormatType.Numeric;
calcEdit1.Properties.DisplayFormat.FormatString = "c2";

See the Formatting Display and Edit Values topic to learn about supported formatting approaches and format specifiers.

If you use the Numeric format (DisplayFormat.FormatType.Numeric), the editor's values must of a numeric data type. If you use the DateTime format (DisplayFormat.FormatType.DateTime), the editor's values must be of the DateTime data type.

In bound mode, the bound field determines the edit value data type. In unbound mode, specify the edit value data type explicitly - by assigning a value of the required data type to the editor's BaseEdit.EditValue property, or by setting the MaskProperties.MaskType property (editor.Properties.Mask.MaskType) to Numeric, DateTime/DateTimeAdvancingCaret.

The DisplayFormat property does not affect how strings being entered in the editor are converted to the editor's underlying data type.

NOTE

LookUp editors do not take into account the RepositoryItem.DisplayFormat and RepositoryItem.EditFormat properties.

Format values in edit and display modes

You can apply a mask to a text editor to restrict input of values and format values in edit and display modes. Mask settings are accessible from the RepositoryItemTextEdit.Mask property. Enable the MaskProperties.UseMaskAsDisplayFormat (editor.Properties.Mask.UseMaskAsDisplayFormat) option to use the specified mask to format the editor's values in display mode.

The following code applies a mask that formats values in a CalcEdit control as currency. The mask formats the editor's values regardless of whether the editor has input focus.

CalcEdit-Mask-UseMaskAsDisplayFormat

calcEdit2.EditValue = 13.654m;
calcEdit2.Properties.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
calcEdit2.Properties.Mask.EditMask = "c2";
calcEdit2.Properties.Mask.UseMaskAsDisplayFormat = true;
See Also