SchedulerControl.AllowAppointmentConflicts Event
Occurs when the scheduler finds appointments that are in conflict, and the OptionsCustomization.AllowAppointmentConflicts property is set to Custom.
Namespace: DevExpress.Xpf.Scheduler
Assembly: DevExpress.Xpf.Scheduler.v14.2.dll
#Declaration
#Event Data
The AllowAppointmentConflicts event's handler receives an argument of the AppointmentConflictEventArgs type. The following properties provide information specific to this event:
Property | Description |
---|---|
Appointment |
Gets the appointment for which the event was raised.
Inherited from Appointment |
Appointment |
Gets the clone of the appointment being processed in the Scheduler |
Conflicts | Gets the collection of appointments which are considered to be in conflict with the current appointment. |
Interval | Gets the time interval for which the event was raised. |
#Remarks
Handle the AllowAppointmentConflicts event to manually decide whether the current appointment conflicts with any other appointments. The appointment's copy to be checked can be accessed via the AppointmentEventArgs.Appointment property.
NOTE
The Allow
This event's arguments provide the AppointmentConflictEventArgs.Conflicts property, which returns the collection of appointments that are considered to be conflicting by the SchedulerControl. All these appointments conflict with the current appointment, since their time intervals intersect and they are assigned the same resource. If the Conflicts collection is empty, this means that there are no conflicting appointments.
The AppointmentConflictEventArgs.AppointmentClone property contains an appointment modified due to an end-user's action. This is the appointment that intersects with existing ones. The Appointment property provides access to the current appointment before modification. So, when an appointment is dragged, its clone may conflict with the original appointment, and the Conflicts collection may contain one element - the original appointment.
NOTE
If you determine that the current appointment has no conflicts, you should clear the Conflicts collection in this event's handler. If you determine that the current appointment has at least one conflict, then the Conflicts collection should contain at least one object that is different from the current appointment. The non-empty Conflicts collection cancels the user's action that caused a conflict. The common practice is to clear the Conflicts collection at the beginning, and populate it with any appointment if the user's action should be canceled. You can even create a fake appointment for this purpose and add it to the collection.
NOTE
The source appointment (accessed via the Appointment
#Examples
This example demonstrates how to prevent end-users from creating appointments within a certain time interval (from 2 PM to 3 PM). To implement end-user restrictions, handle the SchedulerControl.AllowAppointmentCreate event to prevent end-users from creating appointments within a certain time interval and the SchedulerControl.AllowAppointmentConflicts event to prevent an existing appointment from being dragged to the same time interval: