Skip to main content
A newer version of this page is available. .

Access Editor Settings

  • 4 minutes to read

This topic demonstrates how to access editors in a Detail View using a View Controller. This Controller searches the Contact Detail View for a Birthday Property Editor that binds data to a control, and specifies that the control should display touch-UI calendar in its drop down.

Note

We recommend reviewing the following topics before proceeding:

Access Editor Settings in a WinForms Application

  • Add a View Controller called “WinDateEditCalendarController” to the MySolution.Module.Win project as described in the Add a Simple Action lesson (steps 1-3). Switch to code view. Derive the new controller from the ObjectViewController<ViewType, ObjectType>:

    using DevExpress.ExpressApp;
    using MainDemo.Module.BusinessObjects;
    
    namespace MainDemo.Module.Win.Controllers {
        public partial class WinDateEditCalendarController : ObjectViewController<DetailView, Contact> {
            public WinDateEditCalendarController() {
                InitializeComponent();
            }
            // ...
        }
    }
    
  • Override the OnActivated method. Use the DetailViewExtensions.CustomizeViewItemControl(DetailView, Controller, Action<ViewItem>, String[]) method to customize the Birthday View Item‘s control.

The following code demonstrates the WinDateEditCalendarController:

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Editors;
using DevExpress.XtraEditors;
using MainDemo.Module.BusinessObjects;

namespace MainDemo.Module.Win.Controllers {
    public partial class WinDateEditCalendarController : ObjectViewController<DetailView, Contact> {
        public WinDateEditCalendarController() {
            InitializeComponent();
        }
        protected override void OnActivated() {
            base.OnActivated();
            View.CustomizeViewItemControl(this, SetCalendarView, nameof(Contact.Birthday));
        }
        private void SetCalendarView(ViewItem viewItem) {
            DateEdit dateEdit = (DateEdit)viewItem.Control;
            dateEdit.Properties.CalendarView = DevExpress.XtraEditors.Repository.CalendarView.TouchUI;
        }
    }
}

Run the WinForms application and open the Contact Detail View. The Birthday editor shows a touch-UI calendar drop down.

Tutorial_EF_Lesson8_1

Tip

This approach is not applicable to List View’s in-place editors. To customize these editors, do one of the following:

Access Editor Settings in an ASP.NET Application

  • Add a View Controller called “WebDateEditCalendarController“ to the MySolution.Module.Web project as described in the Add a Simple Action topic (steps 1-3). Switch to code view. Derive the new controller from the ObjectViewController<ViewType, ObjectType>:

    using DevExpress.ExpressApp;
    using MainDemo.Module.BusinessObjects;
    
    namespace MainDemo.Module.Web.Controllers {
        public partial class WebDateEditCalendarController : ObjectViewController<DetailView, Contact> {
            public WebDateEditCalendarController() {
                InitializeComponent();
            }
            // ...
        }
    }
    
  • Override the OnActivated method. Use the DetailViewExtensions.CustomizeViewItemControl(DetailView, Controller, Action<ViewItem>, String[]) method to customize the Birthday View Item‘s control.

The following code demonstrates the WebDateEditCalendarController:

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Web.Editors.ASPx;
using DevExpress.Web;
using MainDemo.Module.BusinessObjects;

namespace MainDemo.Module.Web.Controllers {
    public partial class WebDateEditCalendarController : ObjectViewController<DetailView, Contact> {
        public WebDateEditCalendarController() {
            InitializeComponent();
        }
        protected override void OnActivated() {
            base.OnActivated();
            View.CustomizeViewItemControl(this, SetCalendarView, nameof(Contact.Birthday));
        }
        private void SetCalendarView(ViewItem viewItem) {
            var propertyEditor = viewItem as ASPxDateTimePropertyEditor;

            if(propertyEditor != null && propertyEditor.ViewEditMode == ViewEditMode.Edit) {
                ASPxDateEdit dateEdit = propertyEditor.Editor;
                dateEdit.PickerDisplayMode = DatePickerDisplayMode.ScrollPicker;
            }
        }
    }
}

Run the ASP.NET application and open the Contact Detail View. The Birthday editor shows a touch-UI calendar drop down.

Tutorial_EF_Lesson8_3

Tip

This approach does not affect List View’s in-place editors. To customize these editors as well, use the solution described in the How to: Customize a Built-in Property Editor (ASP.NET) topic. Alternatively, access the required in-place Web List Editor as directed in the ComplexWebListEditor.FindPropertyEditor method description. To apply custom settings to an ASPxGridListEditor‘s column, handle the ASPxGridListEditor.CreateCustomGridViewDataColumn and ASPxGridListEditor.CustomizeGridViewDataColumn events. If you need to access a template for displaying cells within the current column, use the ASPxGridListEditor.CreateCustomDataItemTemplate and ASPxGridListEditor.CreateCustomEditItemTemplate events.

 

Next Lesson: Access Grid Control Properties

See Also