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:
- Inherit from the Business Class Library Class (XPO/EF)
- Add a Simple Action
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>:
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 MySolution.Module.BusinessObjects;
namespace MySolution.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.
Tip
This approach is not applicable to List View’s in-place editors. To customize these editors, do one of the following:
- Use a custom property editor as shown in the How to: Customize a Built-in Property Editor (WinForms) topic.
- Access the List Editor control’s events and properties as described in the Access Grid Control Properties article.
Access Editor Settings in an ASP.NET Web Forms 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>:
- 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 MySolution.Module.BusinessObjects;
namespace MySolution.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 Web Forms application and open the Contact Detail View. The Birthday editor shows a touch-UI calendar drop down.
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 Web Forms) 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