Back to Devexpress

End-User Restrictions

wpf-119359-controls-and-libraries-scheduler-end-user-restrictions.md

latest9.3 KB
Original Source

End-User Restrictions

  • Nov 21, 2025
  • 4 minutes to read

The SchedulerControl allows you to prohibit the user to create or edit (delete, drag, etc.) appointments shown within the scheduling area. With the restriction applied, all corresponding UI elements, such as ribbon and popup menu items, are disabled.

Use AllowAppointments… properties to prohibit a specific action for all appointments. Handle the corresponding CustomAllow… event to define custom logic to allow the user to perform an action.

Note

The SchedulerControl uses the CommandManager class to manage commands the ribbon or context menu items execute. The RequerySuggested event is fired when any changes that can affect the command’s ability to execute (for example, changing focus) are made. It notifies the command that it should raise the CanExecuteChanged event, which makes some CustomAllow… events fire as well. This chain of events can occur involuntarily, so make sure that the event handler does not contain any code that may affect the application’s performance.

All the available properties and their corresponding events are listed below. These are all dependency properties.

PropertyDescriptionEvent
SchedulerControl.LimitIntervalGets or sets the time interval available for end-users.
SchedulerControl.AllowAppointmentCreateSpecifies whether creating new appointments is allowed.SchedulerControl.CustomAllowAppointmentCreate
SchedulerControl.AllowAppointmentEditDetermines whether editing existing appointments is allowed.SchedulerControl.CustomAllowAppointmentEdit
SchedulerControl.AllowAppointmentDeleteSpecifies whether deleting appointments is allowed.SchedulerControl.CustomAllowAppointmentDelete
SchedulerControl.AllowAppointmentConflictsIndicates whether sharing the schedule time between two or more appointments is allowed.SchedulerControl.CustomAllowAppointmentConflicts
SchedulerControl.AllowInplaceEditorSpecifies whether invoking the inplace editor is allowed.SchedulerControl.CustomAllowInplaceEditor
SchedulerControl.AllowAppointmentResizeGets or sets whether resizing appointments is allowed.SchedulerControl.CustomAllowAppointmentResize
SchedulerControl.AllowAppointmentDragIndicates whether dragging appointments is allowed.SchedulerControl.CustomAllowAppointmentDrag
SchedulerControl.AllowAppointmentDragBetweenResourcesDetermines whether dragging appointments between resources is allowed.SchedulerControl.CustomAllowAppointmentDragBetweenResources
SchedulerControl.AllowAppointmentCopyGets or sets whether copying appointments is allowed.SchedulerControl.CustomAllowAppointmentCopy
SchedulerControl.AllowAppointmentMultiSelectSpecifies whether selecting more than one appointment is allowed.
SchedulerControl.AllowCellMultiSelectIndicates whether selecting more that one time cell is allowed.
SchedulerControl.AllowRemindersGets or sets whether appointment reminders are allowed.

The code sample below shows how to handle the SchedulerControl.CustomAllowAppointmentCreate event to restrict creating appointments for a specific time interval, and SchedulerControl.CustomAllowAppointmentConflicts event to prohibit dragging appointments to this time interval as well:

View Example

csharp
private void schedulerControl1_CustomAllowAppointmentCreate(object sender, AppointmentItemOperationEventArgs e)
{
    //Retrieve the selected interval:
    DateTimeRange selectedIntervalRange = schedulerControl1.SelectedInterval;
    TimeInterval selectedInterval = new TimeInterval(selectedIntervalRange.Start, selectedIntervalRange.End);

    //Check whether the selected interval intersects with the resticted interval:
    //If true, restrict appointment creation 
    e.Allow = IsIntervalAllowed(selectedInterval);
}
private void schedulerControl1_CustomAllowAppointmentConflicts(object sender, AppointmentItemConflictEventArgs e)
{
    //Obtain the selected interval:
    TimeInterval interval = e.Interval;

    //If the appointment is to be moved to the restricted time interval, 
    //Add the dragged appointment the conflicting appointments collection: 
    if (!IsIntervalAllowed(interval))
        e.Conflicts.Add(e.AppointmentClone);
}
//This method is used to check 
//whether the target interval intersects with the resticted interval:
private bool IsIntervalAllowed(TimeInterval interval)
{
    DateTime dayStart = interval.Start.Date;

    while (dayStart < interval.End)
    {
        if (interval.IntersectsWithExcludingBounds(lunchTime))
            return false;
        dayStart = dayStart.AddDays(1);
    }
    return true;
}
xaml
<dxsch:SchedulerControl Name="schedulerControl1"                                
                        CommandBarStyle="Ribbon"        
                        GroupType="Resource"
                        AllowAppointmentConflicts="False"
                        AllowAppointmentCreate="False"
                        AllowReminders="False"                                
                        FirstDayOfWeek="Monday"                                
                        CustomAllowAppointmentConflicts="schedulerControl1_CustomAllowAppointmentConflicts"
                        CustomAllowAppointmentCreate="schedulerControl1_CustomAllowAppointmentCreate">
vb
Private Sub schedulerControl1_CustomAllowAppointmentCreate(ByVal sender As Object, ByVal e As AppointmentItemOperationEventArgs)
    'Retrieve the selected interval:
    Dim selectedIntervalRange As DateTimeRange = schedulerControl1.SelectedInterval
    Dim selectedInterval As New TimeInterval(selectedIntervalRange.Start, selectedIntervalRange.End)

    'Check whether the selected interval intersects with the resticted interval:
    'If true, restrict appointment creation 
    e.Allow = IsIntervalAllowed(selectedInterval)
End Sub
Private Sub schedulerControl1_CustomAllowAppointmentConflicts(ByVal sender As Object, ByVal e As AppointmentItemConflictEventArgs)
    'Obtain the selected interval:
    Dim interval As TimeInterval = e.Interval

    'If the appointment is to be moved to the restricted time interval, 
    'Add the dragged appointment the conflicting appointments collection: 
    If Not IsIntervalAllowed(interval) Then
        e.Conflicts.Add(e.AppointmentClone)
    End If
End Sub
'This method is used to check 
'whether the target interval intersects with the resticted interval:
Private Function IsIntervalAllowed(ByVal interval As TimeInterval) As Boolean
    Dim dayStart As Date = interval.Start.Date

    Do While dayStart < interval.End
        If interval.IntersectsWithExcludingBounds(lunchTime) Then
            Return False
        End If
        dayStart = dayStart.AddDays(1)
    Loop
    Return True
End Function