Skip to main content

RepositoryItem.DisplayFormat Property

Gets format settings applied to the editor’s value.

Namespace: DevExpress.XtraEditors.Repository

Assembly: DevExpress.XtraEditors.v24.1.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

[DXCategory("Format")]
public virtual FormatInfo DisplayFormat { get; }

Property Value

Type Description
FormatInfo

Format settings.

Remarks

Use the DisplayFormat property to define how the text content is displayed within the editor when the editor does not have input focus. The DisplayFormat property does not modify the actual value stored in the editor (EditValue).

Use the DisplayFormat.FormatType property to specify format type (Numeric, DateTime or Custom). If you use Numeric format (DisplayFormat.FormatType.Numeric), the editor’s value must be of a numeric data type. If you use Date-Time format (DisplayFormat.FormatType.DateTime), the editor’s value must be of the DateTime data type.

The DisplayFormat.FormatString property specifies the format pattern.

The following code snippet formats a CalcEdit‘s value as currency:

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

Tip

Read the following help topic for additional information: Formatting Display and Edit Values.

Note

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

Format Values in Edit and Display Modes

You can apply a mask to a text-based editor to restrict input of values and format values in edit and display modes. Use the MaskSettings property to configure a mask. Enable the UseMaskAsDisplayFormat option to use the editor’s mask to format its value in display mode.

Apply a Numeric Mask to WinForms SpinEdit, DevExpress

spinEdit1.EditValue = 77;
spinEdit1.Properties.MaskSettings.Configure<MaskSettings.Numeric>(settings => {
    settings.MaskExpression = "P0";
    settings.ValueType = typeof(double);
});
spinEdit1.Properties.UseMaskAsDisplayFormat = true;

Enter Date-Time and Numeric Values

See Also