Back to Devexpress

How to: Prevent End-Users from Editing Appointments

windowsforms-2285-controls-and-libraries-scheduler-examples-protection-how-to-prevent-end-users-from-editing-appointments.md

latest4.6 KB
Original Source

How to: Prevent End-Users from Editing Appointments

  • Oct 29, 2020
  • 2 minutes to read

In some real-life applications it might be necessary to prevent end-users from editing (copying, deleting, dragging, etc.) the appointments shown within the SchedulerControl. For instance, it’s necessary to show all the appointments to end-users as read-only.

To do this you should access the customization settings via the SchedulerControl.OptionsCustomization property to implement end-user restrictions in your scheduling application. The following restrictions are possible in the XtraScheduler:

RestrictionDescription
SchedulerOptionsCustomization.AllowAppointmentConflictsSpecifies whether an end-user is allowed to share the schedule time between two or more appointments.
SchedulerOptionsCustomization.AllowAppointmentCopySpecifies whether an end-user is allowed to copy appointments.
SchedulerOptionsCustomization.AllowAppointmentCreateSpecifies whether an end-user is allowed to create new appointments.
SchedulerOptionsCustomization.AllowAppointmentDeleteSpecifies whether an end-user is allowed to delete appointments.
SchedulerOptionsCustomization.AllowAppointmentDragSpecifies whether an end-user is allowed to drag and drop appointments to another time slot or date.
SchedulerOptionsCustomization.AllowAppointmentDragBetweenResourcesSpecifies whether an end-user is allowed to drag and drop appointments between resources.
SchedulerOptionsCustomization.AllowAppointmentEditSpecifies whether an end-user is allowed to edit appointments.
SchedulerOptionsCustomization.AllowAppointmentMultiSelectSpecifies whether an end-user is allowed to select more than one appointment simultaneously.
SchedulerOptionsCustomization.AllowAppointmentResizeSpecifies whether an end-user is allowed to change the time boundaries of appointments.
SchedulerOptionsCustomization.AllowInplaceEditorSpecifies whether an in-place editor can be activated for an appointment.

You can set a corresponding value as required, e.g. set it ot UsedAppointmentType.None to prohibit a particular action for all appointment types, or set it to UsedAppointmentType.Recurring to allow it for recurring appointments only.

If you set one of OptionsCustomization.Allow* properties to UsedAppointmentType.Custom, a related Allow* event will fire, in which you can decide how to handle a particular case. For example, to prevent user Sam from dragging appointments, you can use the following code:

csharp
schedulerControl1.OptionsCustomization.AllowAppointmentDrag = UsedAppointmentType.Custom;
schedulerControl1.AllowAppointmentDrag += new AppointmentOperationEventHandler
(schedulerControl1_AllowAppointmentDrag);

// ...

void schedulerControl1_AllowAppointmentDrag(object sender, AppointmentOperationEventArgs e) {
    if (user_id == "Sam") e.Allow = false;
}
vb
Private schedulerControl1.OptionsCustomization.AllowAppointmentDrag = UsedAppointmentType.Custom
Private schedulerControl1.AllowAppointmentDrag += New AppointmentOperationEventHandler _
(schedulerControl1_AllowAppointmentDrag)

' ...

Private Sub schedulerControl1_AllowAppointmentDrag(ByVal sender As Object, _
ByVal e As AppointmentOperationEventArgs)
    If user_id = "Sam" Then
    e.Allow = False
    End If
End Sub