Skip to main content
All docs
V24.2
.NET 8.0+

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to: Access the Scheduler Control in Code

  • 2 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

C#
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

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

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;
            }
        }
    }
}