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 Based on a Custom Control (WinForms)

This topic explains how to implement a Property Editor for WinForms applications. For demo purposes, the integer Property Editor based on the NumericUpDown control is implemented in this example.

Note

  • You can see the code implemented here in the FeatureCenter Demo, installed with XAF. This demo is located in the %PUBLIC%\Documents\DevExpress Demos 17.1\Components\eXpressApp Framework\FeatureCenter folder, by default.
  • If you intend to use a DevExpress WinForms control that is not integrated to XAF by default, refer to the How to: Implement a Property Editor Using a DevExpress WinForms Control topic.

Follow these steps to implement a WinForms Property Editor.

  1. In the WinForms module project, inherit the PropertyEditor or WinPropertyEditor class. Note that your editor should be public.
  2. Apply the PropertyEditorAttribute to specify the data type for which the Property Editor will be used (Int32 in this example). If you pass true to the PropertyEditor attribute's last parameter, the Property Editor will be used for all integer properties in any business class.
  3. Override the CreateControlCore method. In this method, instantiate, initialize and return the control instance (the NumericUpDown control in this example).
  4. Determine which event of the control occurs when the editing value is changed by a user (e.g., the NumericUpDown.ValueChanged event). Refer to the control's documentation to find the appropriate event. Subscribe to this event and call the OnControlValueChanged method (which internally raises the PropertyEditor.ControlValueChanged event) from the event handler.
  5. Override the Dispose method and unsubscribe the event handled in the previous step.
  6. Optionally, support the IInplaceEditSupport interface and implement the IInplaceEditSupport.CreateRepositoryItem method. This step is only required if you are going to make the column editable in the editable List View.

The following code demonstrates CustomIntegerEditor class implementation based on the steps above.

To display a particular property using the CustomIntegerEditor Property Editor, customize the Application Model. Invoke the Model Editor for the WinForms module project and navigate to the required BOModel | Class | OwnMembers | Member node. Set the node's IModelCommonMemberViewItem.PropertyEditorType property to CustomIntegerEditor. After this, the property specified by the Member node will be displayed by the CustomIntegerEditor in all Views. To use a CustomIntegerEditor Property Editor in a specific Detail View only, use the PropertyEditorType property of the Views | <DetailView> | Items | <PropertyEditor> node instead.

Note

You may need to implement the IAppearanceFormat interface and manually apply the IAppearanceFormat.BackColor, IAppearanceFormat.FontColor and IAppearanceFormat.FontStyle settings of the Conditional Appearance Module to the created control.

Expanded See Also

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