New to Telerik UI for WinFormsStart a free 30-day trial

How to modify mouse wheel scroll value in RadScheduler's MonthView

Updated over 6 months ago

Environment

Product VersionProductAuthor
2023.1.117RadScheduler for WinFormsDinko Krastev

Description

By design, when using the mouse wheel the Month View in RadScheduler weeks section is scrolled by 1 week. There could be a requirement to change this value by more than 1 week.

Solution

By default, the SchedulerInputBehavior is responsible for processing the keyboard and mouse input. In this case, we can create a custom input behavior and override the HandleMouseWheel() method. Inside the method, you can offset the view by 2 weeks instead of 1.

C#
        
public class MySchedulerInputBehavior : SchedulerInputBehavior
{
    public MySchedulerInputBehavior(RadScheduler scheduler)
        : base(scheduler)
    {
    }
    public override bool HandleMouseWheel(MouseEventArgs args)
    {
        // return base.HandleMouseWheel(args);
        if (args.Delta > 0)
        {
            //this.Scheduler.ViewElement.Scroll(true);
            SchedulerMonthView monthView = this.Scheduler.GetMonthView();
            SchedulerMonthView offsetView = (SchedulerMonthView)monthView.OffsetView(-2);
            monthView.StartDate = offsetView.StartDate;
        }
        else
        {
            //  this.Scheduler.ViewElement.Scroll(false);
            SchedulerMonthView monthView = this.Scheduler.GetMonthView();
            SchedulerMonthView offsetView = (SchedulerMonthView)monthView.OffsetView(2);
            monthView.StartDate = offsetView.StartDate;
        }
        return false;
    }
}

See Also