Log In
[Expand]General Information
[Expand]WinForms Controls
[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
[Collapse]eXpressApp Framework
 [Expand]Getting Started
 [Expand]Design-Time Features
 [Collapse]Task-Based Help
  [Expand]Business Model Design
  [Expand]Application Model
  [Expand]List Editors
  [Collapse]Property Editors
    How to: Customize a Built-in Property Editor (ASP.NET)
    How to: Customize a Built-in Property Editor (Mobile)
    How to: Customize a Built-in Property Editor (WinForms)
    How to: Disable and Hide Property Editors Based on a Business Rule
    How to: Display an Integer Property as an Enumeration
    How to: Implement a Property Editor Based on a Custom Control (WinForms)
    How to: Implement a Property Editor Based on Custom Controls (ASP.NET)
    How to: Implement a Property Editor Using a DevExpress WinForms Control
    How to: Supply Predefined Values for the String Property Editor Dynamically (ASP.NET)
    How to: Supply Predefined Values for the String Property Editor Dynamically (WinForms)
    How to: Use Criteria Property Editors
  [Expand]Scheduler and Notifications
  [Expand]Miscellaneous UI Customizations
  Frequently Asked Questions (FAQ)
 [Expand]API Reference
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
This documentation page describes implementations made in our v17.2 release cycle. To learn about functionality shipping with v18.1, navigate to our updated help file experience at docs.devexpress.com. Learn More

How to: Implement a Property Editor Using a DevExpress WinForms Control

This topic demonstrates how to implement a Property Editor with a custom mask. This Property Editor will use the CalcEdit editor from the XtraEditors library. A currency mask will be set for this editor.

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E232.

The image below shows the resulting Property Editor:


Since we are going to use an editor from the XtraEditors library, our Property Editor should be inherited from the DXPropertyEditor class. This class supports the editor's capability to be used for inplace editing. It exposes extra methods for this. Note that your editor should be public.

When implementing a Property Editor, you should apply the PropertyEditor attribute to it. This attribute represents an indicator for the Application Model loader. The classes that use this attribute can be set to display properties of the type specified by the attribute's parameter.

Now, our Property Editor will be available within the Property Editor types that can display decimal properties. To set a Property Editor to be automatically used for all properties of a specified data type, pass true as the second attribute parameter.

The DXPropertyEditor class sets the control's EditValue property as a binding property. However, the CalcEdit control converts the edit value to the Decimal type. The editor's decimal value can be accessed via the Value property. So, we can set the Value property as a binding property.

To specify the CalcEdit editor as a control that will be used to display the Property Editor's property, override the CreateControlCore method:

To specify the required settings for our Property Editor, we need to override the SetupRepositoryItem method (see DXPropertyEditor). This method's item parameter specifies the default repository item created for the CalcEdit editor (see CalcEdit.Properties).

In the code above, the Currency mask is set for the editor. The same mask is set to be used as a display format.

To use our Property Editor inplace, for example, in an editable GridListEditor, we should override the CreateRepositoryItem method, and return the required repository item.


Overriding the CreateRepositoryItem method is optional. This is only required if you are going to use the Property Editor in a cell of an editable List Editor. Note that a new PropertyEditor object is created to initialize the GridColumn.ColumnEdit property and then this object is immediately disposed. So, the custom PropertyEditor descendant is an incorrect place for event handlers. Instead, handle events or override corresponding protected virtual methods in your RepositoryItem class, introduce necessary properties and initialize them in the CreateRepositoryItem method of your Property Editor.

To see our Property Editor in use, set it for a decimal property in the Model Editor invoked for the Windows Forms application project. To do this, use the PropertyEditorType property of the BOModel | <Class> | OwnMembers | <Member> or the Views | <DetailView> | Items | <PropertyEditor> node.

Expanded See Also

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