Back to Devexpress

WinPropertyEditor Class

expressappframework-devexpress-dot-expressapp-dot-win-dot-editors-a469c62d.md

latest5.7 KB
Original Source

WinPropertyEditor Class

Represents a base class for Windows Forms Property Editors.

Namespace : DevExpress.ExpressApp.Win.Editors

Assembly : DevExpress.ExpressApp.Win.v25.2.dll

NuGet Packages : DevExpress.ExpressApp.Win, DevExpress.ExpressApp.Win.Design

Declaration

csharp
public abstract class WinPropertyEditor :
    PropertyEditor,
    ISupportToolTip
vb
Public MustInherit Class WinPropertyEditor
    Inherits PropertyEditor
    Implements ISupportToolTip

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:

MemberDescription
WinPropertyEditor.ControlProvides access to the control that represents the current Property Editor in a UI.
WinPropertyEditor.ControlBindingPropertySpecifies the control’s property that is used for data binding.
WinPropertyEditor.TextControlHeightReturns 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.

  • C#

csharp
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).

Implements

IAppearanceEnabled

IAppearanceVisibility

INotifyAppearanceVisibilityChanged

Inheritance

Object ViewItem PropertyEditor WinPropertyEditor DXPropertyEditor

See Also

WinPropertyEditor Members

PropertyEditor

Property Editors

Implement a Property Editor Based on a Custom Control (WinForms)

PropertyEditorAttribute

DevExpress.ExpressApp.Win.Editors Namespace