How to: Access the List Editor's Control

This article describes how to access any List Editor's control. Use this approach in WinForms, ASP.NET and Mobile applications to change how the control is displayed.

The example below demonstrates how to set an 8AM-5PM time interval for the WinForms Scheduler Module's SchedulerControl.

SchedulerControl_Access

Tip

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E225.

Access and modify the SchedulerControl by following the steps below:

  1. Add the Scheduler Module to your WinForms module project.
  2. Add the Event business class to the platform-agnostic module project, as shown in the Add a Class from the Business Class Library and Use the Scheduler Module (XPO/EF) topic.
  3. Create a new ObjectViewController<ViewType, ObjectType> descendant called "WinSchedulerController". Set the Controller's ViewType parameter to ListView, and the ObjectType parameter to IEvent - the interface the Event business class implements.
  4. Override the OnViewControlsCreated method to access the SchedulerControl directly after the control's creation.
  5. Set the SchedulerControl's DayView.VisibleTime property to a new interval, 8AM-5PM.

The following code demonstrates the WinSchedulerController:

using DevExpress.XtraScheduler;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Scheduler.Win;
using DevExpress.Persistent.Base.General;
// ...
public class WinSchedulerController : ObjectViewController<ListView, IEvent> {
    protected override void OnViewControlsCreated() {
        base.OnViewControlsCreated();
        SchedulerListEditor listEditor = View.Editor as SchedulerListEditor;
        if (listEditor != null) {
            SchedulerControl scheduler = listEditor.SchedulerControl;
            scheduler.Views.DayView.VisibleTime =
                new TimeOfDayInterval(new TimeSpan(8, 0, 0), new TimeSpan(17, 0, 0));
        }
    }
}

Run the WinForms application and make sure that the visible time interval is between 8 AM and 5 PM (see the image above).

Similarly, you can access the ASPxSchedulerListEditor and its ASPxScheduler control in ASP.NET applications.