Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Collapse]eXpressApp Framework
 [Expand]Fundamentals
 [Expand]Getting Started
 [Expand]Concepts
 [Expand]Design-Time Features
 [Expand]Functional Testing
 [Expand]Deployment
 [Collapse]Task-Based Help
  [Expand]Business Model Design
  [Expand]Application Model
  [Expand]Actions
  [Expand]Navigation
  [Expand]Views
  [Expand]List Editors
  [Collapse]Property Editors
    How to: Customize a Built-in Property Editor (ASP.NET)
    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]Templates
  [Expand]Filtering
  [Expand]Reporting
  [Expand]Dashboards
  [Expand]Scheduler and Notifications
  [Expand]Maps
  [Expand]Security
  [Expand]Workflow
  [Expand]Localization
  [Expand]Testing
  [Expand]Miscellaneous UI Customizations
 [Expand]Frequently Asked Questions
 [Expand]API Reference
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
[Expand]End-User Documentation

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

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

Note

Overriding the CreateRepositoryItem method is optional. This is only required if you are going to have an editor inplace, for example, in an editable GridListEditor.

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

How would you rate this topic?​​​​​​​