WinPropertyEditor Class
Represents a base class for Windows Forms Property Editors.
Namespace: DevExpress.ExpressApp.Win.Editors
Assembly: DevExpress.ExpressApp.Win.v24.2.dll
NuGet Packages: DevExpress.ExpressApp.Win, DevExpress.ExpressApp.Win.Design
Declaration
Remarks
Inherit from this class, to implement a custom Windows Forms Property Editor using a standard control that supports binding. If the control does not support binding, inherit from the PropertyEditor class. To implement a custom Property Editor based on a control derived from BaseEdit, inherit from the DXPropertyEditor class.
Compared to the PropertyEditor class, the WinPropertyEditor class introduces additional members:
Member | Description |
---|---|
WinPropertyEditor.Control | Provides access to the control that represents the current Property Editor in a UI. |
WinPropertyEditor.ControlBindingProperty | Specifies the control’s property that is used for data binding. |
WinPropertyEditor.TextControlHeight | Returns the default control height in pixels. Used by the XAF built-in Property Editors. |
The simplest implementation of the WinPropertyEditor class’ descendant requires the following:
- Override the CreateControlCore method. Create and return an instance of the required control in this method.
- Determine which event of the control occurs when the editing value is changed by a user (refer to the control’s documentation to find the appropriate event). Subscribe to this event and call the OnControlValueChanged method from the event handler.
- Specify the WinPropertyEditor.ControlBindingProperty value in the constructor or in the CreateControlCore method.
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.Win.Editors;
// ...
[PropertyEditor(typeof(int), false)]
public class MyPropertyEditor : WinPropertyEditor {
public MyPropertyEditor(Type objectType, IModelMemberViewItem model) : base(objectType, model) { }
protected override object CreateControlCore() {
System.Windows.Forms.TrackBar trackbarControl = new System.Windows.Forms.TrackBar();
trackbarControl.Minimum = 0;
trackbarControl.Maximum = 100;
trackbarControl.Scroll += trackbarControl_Scroll;
this.ControlBindingProperty = "Value";
return trackbarControl;
}
void trackbarControl_Scroll(object sender, EventArgs e) {
this.OnControlValueChanged();
}
}
Tip
Set the CanUpdateControlEnabled protected property to true in the constructor of your custom Property Editor if it is required to update the Control.Enabled property value (e.g., when the underlying control is created or the PropertyEditor.AllowEdit property is changed).