Skip to main content
.NET Standard 2.0+

Customize a Built-in Property Editor (WinForms)

  • 3 minutes to read

This topic describes how to customize a built-in XAF Property Editor for WinForms applications (refer to the How to: Customize a Built-in Property Editor (ASP.NET Web Forms) topic to see the similar example for ASP.NET Web Forms). In this example, the DatePropertyEditor is customized to display the calendar and the clock:



You can see the code demonstrated here, along with more examples on custom property editors in the Feature Center Demo installed with XAF. The Feature Center demo is installed in %PUBLIC%\Documents\DevExpress Demos 22.1\Components\XAF\FeatureCenter.NETFramework.XPO. The ASP.NET Web Forms version of this demo is available online at

Inherit the Property Editor

Inherit the DatePropertyEditor class in the WinForms module project. If your solution does not contain this project, add the Controller to the WinForms application project. Note that your editor should be public. Since this class is the DXPropertyEditor class descendant, its settings can be accessed using the Repository Item. To apply the customization to the controls created in both the Detail View and List View, override the SetupRepositoryItem method. The PropertyEditor attribute is applied to the implemented Property Editor, to specify that it can be used for the DateTime type properties:

using DevExpress.Utils;
using DevExpress.XtraEditors.Repository;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Model;
using DevExpress.ExpressApp.Win.Editors;
[PropertyEditor(typeof(DateTime), false)]
public class CustomDateTimeEditor : DatePropertyEditor {
    public CustomDateTimeEditor(Type objectType, IModelMemberViewItem info) : 
        base(objectType, info) { }
    protected override void SetupRepositoryItem(RepositoryItem item) {
        RepositoryItemDateTimeEdit dateProperties = (RepositoryItemDateTimeEdit)item;
        dateProperties.CalendarTimeEditing = DefaultBoolean.True;
        dateProperties.CalendarView = CalendarView.Vista;

Use the Customized Property Editor

To use the implemented Property Editor for a specific property, run the Model Editor in the WinForms project and set the IModelCommonMemberViewItem.PropertyEditorType of the required OwnMember or ViewItem node to CustomDateTimeEditor.


To use the implemented Property Editor for all DateTime properties, set the PropertyEditorAttribute constructor’s defaultEditor parameter to true in the code above. The CompositeView.GetItems<T> method allows you to use a custom Property Editor for all properties instead of the default Property Editor.

Note that the business class’ property value associated with the created Property Editor should be formatted in order to display the time part of the DateTime value

using DevExpress.ExpressApp.Model;
private DateTime createdOn;
[ModelDefault("DisplayFormat", "{0:MM.dd.yyyy hh:mm:ss}")]
[ModelDefault("EditMask", "MM.dd.yyyy hh:mm:ss")]
public DateTime CreatedOn {
    get { return createdOn; }
    set { SetPropertyValue(nameof(CreatedOn), ref createdOn, value); }

For details, refer to the Format a Property Value topic.

See Also