Skip to main content

AppointmentOperationEventArgs Class

Provides data for the AllowAppointment events of the SchedulerControl.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v23.2.Core.Desktop.dll

NuGet Package: DevExpress.Scheduler.CoreDesktop

Declaration

public class AppointmentOperationEventArgs :
    AppointmentEventArgs

Remarks

The AllowAppointment events occur when an end-user tries to perform a particular action, which is defined by this AllowAppointment event, and the corresponding AllowAppointment property of the SchedulerControl.OptionsCustomization object is set to Custom. The AppointmentOperationEventArgs class introduces the AppointmentOperationEventArgs.Allow property that specifies whether the particular action is allowed to be performed by an end-user or not. The processed appointment is identified by the AppointmentEventArgs.Appointment property.

An instance of the AppointmentOperationEventArgs class with appropriate settings is automatically created and passed to the corresponding event’s handler.

Example

This example demonstrates how to implement custom rules for editing and deleting appointments. The code below allows an appointment to be edited only by its owner (the end-user who created it). To do this it’s necessary to set the SchedulerOptionsCustomization.AllowAppointmentEdit and SchedulerOptionsCustomization.AllowAppointmentDelete properties to UsedAppointmentType.Custom, and handle the SchedulerControl.AllowAppointmentEdit and SchedulerControl.AllowAppointmentDelete events to implement custom logic for editing appointments.

using DevExpress.XtraScheduler;
// ...

private void schedulerControl1_AllowAppointmentDelete(object sender, 
    AppointmentOperationEventArgs e) {
   // Allow only the user who created this appontment to delete it.
   e.Allow = CanUserModifyThisAppointment(e.Appointment);
}
private void schedulerControl1_AllowAppointmentEdit(object sender, 
    AppointmentOperationEventArgs e) {
   // Allow only the user who created this appontment to modify it.
   e.Allow = CanUserModifyThisAppointment(e.Appointment);
}
// Determine if the current user is the same 
// as the one who created the specified appointment 
bool CanUserModifyThisAppointment(Appointment apt) {
   object obj = apt.CustomFields["Owner"];
   if (obj == null)
      return true;
   string appointmentOwner = obj.ToString();
   if (appointmentOwner == String.Empty)
      return true;
   return (String.Compare(appointmentOwner, tbUserName.Text, true) == 0);
}

Inheritance

Object
EventArgs
AppointmentEventArgs
AppointmentOperationEventArgs
See Also