Skip to main content
A newer version of this page is available. .

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.v17.2.dll

Declaration

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

Property Value

Type Description
FormatInfo

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

Remarks

This property defines the settings used to format display values when an editor doesn’t have input focus. These settings allow you to apply formatting, using approaches described in Formatting Display and Edit Values.

To specify how the editor’s edit value is represented when the editor has focus, use masks. Text editors introduce the RepositoryItemTextEdit.Mask property, which specifies the edit mask and various mask settings. Masks can also be used to format values when the editor does not have focus. To enable this feature, set the MaskProperties.UseMaskAsDisplayFormat property to true.

Note that format settings specified by the DisplayFormat property are not in effect when the editor has focus, and do not affect how strings being entered within an editor are converted to an underlying type. For example, if an editor is intended to accept numeric or date-time values, we suggest you use masks. To do this, set the editor’s MaskProperties.MaskType property to Numeric or DateTime (DateTimeAdvancingCaret), and then specify the required mask via the MaskProperties.EditMask property. Using masks ensures that values are entered using a specific pattern, and the entered strings are automatically converted to a corresponding numeric or DateTime type. If you do not want to use masks, the entered strings should be converted to a corresponding underlying type manually, by handling the RepositoryItem.ParseEditValue event.

Note

Formatting imposed by the DisplayFormat property is in effect when the type of the editor’s value matches the DisplayFormat.FormatType property’s value (FormatInfo.FormatType). So, if the FormatType property is set to Numeric, the editor must display numeric values. If the FormatType property is set to DateTime, the editor’s values must be of the date-time type. In bound mode, the type of the editor’s value is determined by the type of the bound field. In unbound mode, the type of values must be specified explicitly: by assigning a value of the required type to the editor’s BaseEdit.EditValue property, or by setting the MaskProperties.MaskType property of the RepositoryItemTextEdit.Mask object to Numeric, DateTime or DateTimeAdvancingCaret.

Note

The RepositoryItem.DisplayFormat and RepositoryItem.EditFormat properties are not supported by: 1) Editors that do not provide the text editing feature 2) Lookup editors.

The following code snippets (auto-collected from DevExpress Examples) contain references to the DisplayFormat 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