Format and Parse Editor Values

  • 2 minutes to read

Formatting

Each editor presents its data (edit value) in a specific manner (as a string, picture, check box, etc.). For a standalone editor, its edit value can be set and read using the editor’s BaseEdit.EditValue property (this property is bindable). For editors embedded into container controls (e.g., GridControl, and TreeList), the editor’s value is provided by the parent container control. For instance, when an editor is embedded in a GridControl’s cell, the grid supplies data to the editor by obtaining it from an underlying data source.

When an edit value is about to be displayed onscreen by the editor, the formatting mechanism is invoked, which translates the edit value into the display value (or display text for text editors).

Before the default formatting mechanism is invoked, you can substitute the edit value with another one by handling the editor’s FormatEditValue event (RepositoryItem.FormatEditValue or BaseEdit.FormatEditValue; the latter is only available for standalone editors). After your event handler is complete, the new value will be formatted using the default formatting mechanism.

To customize display formatting settings of editors, use the RepositoryItem.DisplayFormat property. See Formatting to learn more.

To enable masked input, use the RepositoryItemTextEdit.Mask property. More information is available in Input Mask.

Parsing

Each time an end-user accepts an edit value or a new value is assigned to the editor in code, the input value is converted to the editor’s data type (numeric, date-time, etc.). For instance, this occurs when the editor is about to lose focus when the ENTER key is pressed (if the RepositoryItemTextEdit.ValidateOnEnterKey property value is true) or when a value is assigned to the BaseEdit.EditValue property in code. You can override the default conversion by handling the RepositoryItem.ParseEditValue event.

Formatting and Parsing Values in Data Bound Editors

Data bound editors obtain their values by reading them from a data source, and save modified data by positing it back to the data source. To replace values transferred from a data source to bound editors, handle the Format event. To replace values transferred from bound editors to the data source, handle the Parse event.