Skip to main content
All docs
V23.2

How to: Access the Scheduler Control in Code

  • 3 minutes to read

To access the control in code, create a View Controller and override its OnActivated method. Set the Controller’s ViewController.TargetViewType property to ListView. This way the Controller is activated for List Views only.

ASP.NET Core Blazor

File:
YourApplicationName.Blazor.Server\Controllers\SchedulerController.cs.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Scheduler.Blazor;
using DevExpress.ExpressApp.Scheduler.Blazor.Editors;
using DevExpress.Persistent.Base.General;

namespace YourApplicationName.Module.Controllers {
    public partial class SchedulerController : ObjectViewController<ListView, IEvent> {
        protected override void OnViewControlsCreated() {
            base.OnViewControlsCreated();
            if(View.Editor is SchedulerListEditor schedulerListEditor) {
                // Obtain an instance of the DxSchedulerModel type.
                schedulerListEditor.SchedulerModel.ActiveViewType = DevExpress.Blazor.SchedulerViewType.WorkWeek;
            }
        }
    }
}

For more information on how to access the Scheduler control in code, refer to the following examples:

Windows Forms

File:
YourApplicationName.Win\Controllers\SchedulerController.cs in solutions without the WinForms-specific module project. YourApplicationName.Module.Win\Controllers\SchedulerController.cs(.vb) in solutions with the WinForms-specific module project.

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Scheduler.Win;
using DevExpress.Persistent.Base.General;
using DevExpress.XtraScheduler;
namespace YourApplicationName.Module.Controllers {
    public partial class SchedulerController : ObjectViewController<ListView, IEvent> {
        protected override void OnViewControlsCreated() {
            base.OnViewControlsCreated();
            if(View.Editor is SchedulerListEditor schedulerListEditor) {
                SchedulerControl scheduler = schedulerListEditor.SchedulerControl;
            }
        }
    }
}

Note

If the CrossThreadFailure error occurs when you handle SchedulerControl events, set the control’s SchedulerOptionsBehavior.UseAsyncMode option to false.

For more information on how to access the Scheduler control in code, refer to the following examples:

ASP.NET Web Forms

File:
MySolution.Module.Web\Controllers\SchedulerController.cs(.vb).

using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Scheduler.Web;
using DevExpress.Persistent.Base.General;
using DevExpress.Web.ASPxScheduler;

namespace YourApplicationName.Module.Controllers {
    public partial class SchedulerController : ObjectViewController<ListView, IEvent> {
        //...
        protected override void OnViewControlsCreated() {
            base.OnViewControlsCreated();
            if(View.Editor is ASPxSchedulerListEditor schedulerListEditor) {
                ASPxScheduler scheduler = schedulerListEditor.SchedulerControl;
            }
        }
    }
}