New to Telerik UI for WinForms? Download free 30-day trial

Scheduler Selection

Cell selection

The end user is allowed to perform a single cell selection pressing the left/right mouse button. In order to select a range of cells, it is necessary to hold the Shift key pressed while pressing the mouse button over a specific cell or by dragging through a range of cells. The CellSelectionChanging and the CellSelectionChanged events are fired when the cell selection is altered. The SchedulerCellSelectingEventArgs gives you additional information for the selection range.

Appointment selection

The end user is allowed to perform a single appointment selection pressing the left/right mouse button. In order to select a range of appointments, it is necessary to set the AllowAppointmentsMultiSelect property to true and hold the Ctrl key pressed while pressing the mouse button over a certain appointment. You can track the appointments selection changes using the AppointmentSelecting and the AppointmentSelected events. The SchedulerAppointmentCancelEventArgs and the SchedulerAppointmentSelectedEventArgs give you additional information about the performed selection.

Using the SelectionBehavior

SchedulerSelectionBehavior performs selection operations and provides information about the current selection of cells and appointments in RadScheduler.

  • Getting the current cell selection: The SelectionBehavior.CurrentCell and the SelectionBehavior. CurrentCellElement properties return the current cell position and the currently selected SchedulerCellElement respectively. In addition, it is possible to access the range of the selected cells. The SelectionBehavior.SelectionStartDate property returns the start date of the currently selected cell/cell range. The SelectionBehavior.SelectionEndDate property returns the end date of the currently selected cell/cell range. In order to detect whether there are selected cells, use the HasCellsSelected property.

  • Getting the selected appointment and selected appointments: The SelectionBehavior.SelectedAppointment property returns the currently selected appointment. If the AllowAppointmentsMultiSelect property is set to true, you can use the SelectionBehavior.SelectedAppointments property, which returns a collection the currently selected appointments. In order to detect whether there are selected appointments, use the HasAppointmentsSelected property.

  • Programmatically selecting cells and appointments: there are several methods, which allows you to modify the selection.

Method Description
SelectAppointment(IEvent appointment, bool extend) Selects an appointment given as parameter. The extend parameter indicates whether the selection will be extended or not.If multiple selection is allowed and the extend parameter is true, the appointment, given as parameter, will be added to the SelectedAppointments collection. If this appointment is currently selected, calling the SelectAppointment method will unselect it. If the extend parameter is false, the appointment, given as parameter, will remain the only selected appointment, no matter if it is currently selected or not. If multiple selection is not allowed, the appointment, given as parameter, will remain the only selected appointment.
UnselectAppointment(IEvent appointment) Unselects the specific appointment.
ResetAppointmentSelection Clears all selected appointments.
IsAppointmentSelected(IEvent appointment) Indicates whether a specific appointment is selected or not.
ResetCellSelection Clears the selected cells.
IsDateSelected(DateTime date, TimeSpan duration, EventId resourceId, bool isAllDayAreaCell) Determines whether a specific date is selected for the certain resource id.
SelectCell(SchedulerCellElement cell) Selects a specific cell.
SelectCell(SchedulerCellElement cell, bool extendSelection) Selects a specific cell with option to extend or not the selection (as if the Shift key is pressed).
IsCellSelected(SchedulerCellElement cell) Determines whether a specific cell is selected.
SelectDateRange(DateTime startDate, DateTime endDate) Selects cells in the specified range. If the current cell belongs to a specific resource, the cells in the desired range for this resource will be selected.
SelectDateRange(DateTime startDate, DateTime endDate, EventId resourceId) Selects cells in the specified range for the certain resource id.
GetCellDuration Returns the cell duration according to the current view.
ResetSelection Clears all selected appointments and cells.

Custom SelectionBehavior

The default behavior of the RadScheduler selection can be modified programmatically.

1. This can be achieved by creating a derivative of the SchedulerSelectionBehavior:

Custom Selection Class

public class CustomSchedulerSelectionBehavior : SchedulerSelectionBehavior
    public CustomSchedulerSelectionBehavior(RadScheduler scheduler) : base(scheduler)

Public Class CustomSchedulerSelectionBehavior
Inherits SchedulerSelectionBehavior
    Public Sub New(scheduler As RadScheduler)
    End Sub
End Class

2. Override the SelectAppointment method and allow selection only for appointments off work hours:

Override Method

public override void SelectAppointment(IEvent appointment, bool extend)
    SchedulerDayView dayView = this.Scheduler.GetDayView();

    if (dayView.IsWorkTime(appointment.Start))
    base.SelectAppointment(appointment, extend);

Public Overrides Sub SelectAppointment(appointment As IEvent, extend As Boolean)
    Dim dayView As SchedulerDayView = Me.Scheduler.GetDayView()
    If dayView.IsWorkTime(appointment.Start) Then
    End If
    MyBase.SelectAppointment(appointment, extend)
End Sub

3. Apply this behavior to the RadScheduler:

Set Behavior

this.radScheduler1.SelectionBehavior = new CustomSchedulerSelectionBehavior(this.radScheduler1);

Me.RadScheduler1.SelectionBehavior = New CustomSchedulerSelectionBehavior(Me.RadScheduler1)

See Also

In this article