[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Collapse]Editors and Simple Controls
    Included Controls and Components
   [Collapse]Common Editor Features and Concepts
    [Expand]Input Mask
    [Collapse]Format and Parse Editor Values
     Custom Editors
   [Expand]Lookup Editors
    Popup Container Editor
   [Expand]Token Edit Control
   [Expand]Breadcrumb Edit Control
   [Expand]Range Control
   [Expand]Image Slider
    Camera Control
    Templated ListBox Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Format and Parse Editor Values

Expanded 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.

Expanded 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.

Expanded 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 System.Windows.Forms.Binding.Format event. To replace values transferred from bound editors to the data source, handle the System.Windows.Forms.Binding.Parse event.

Is this topic helpful?​​​​​​​