Skip to main content

End-User Restrictions

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

Property Description Event
SchedulerControl.LimitInterval Gets or sets the time interval available for end-users.
SchedulerControl.AllowAppointmentCreate Specifies whether creating new appointments is allowed. SchedulerControl.CustomAllowAppointmentCreate
SchedulerControl.AllowAppointmentEdit Determines whether editing existing appointments is allowed. SchedulerControl.CustomAllowAppointmentEdit
SchedulerControl.AllowAppointmentDelete Specifies whether deleting appointments is allowed. SchedulerControl.CustomAllowAppointmentDelete
SchedulerControl.AllowAppointmentConflicts Indicates whether sharing the schedule time between two or more appointments is allowed. SchedulerControl.CustomAllowAppointmentConflicts
SchedulerControl.AllowInplaceEditor Specifies whether invoking the inplace editor is allowed. SchedulerControl.CustomAllowInplaceEditor
SchedulerControl.AllowAppointmentResize Gets or sets whether resizing appointments is allowed. SchedulerControl.CustomAllowAppointmentResize
SchedulerControl.AllowAppointmentDrag Indicates whether dragging appointments is allowed. SchedulerControl.CustomAllowAppointmentDrag
SchedulerControl.AllowAppointmentDragBetweenResources Determines whether dragging appointments between resources is allowed. SchedulerControl.CustomAllowAppointmentDragBetweenResources
SchedulerControl.AllowAppointmentCopy Gets or sets whether copying appointments is allowed. SchedulerControl.CustomAllowAppointmentCopy
SchedulerControl.AllowAppointmentMultiSelect Specifies whether selecting more than one appointment is allowed.
SchedulerControl.AllowCellMultiSelect Indicates whether selecting more that one time cell is allowed.
SchedulerControl.AllowReminders Gets 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

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