A newer version of this page is available. Switch to the current version.

AppointmentConflictEventArgs Class

Provides data for the SchedulerControl.AllowAppointmentConflicts event.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v18.2.Core.dll


public class AppointmentConflictEventArgs :
Public Class AppointmentConflictEventArgs
    Inherits AppointmentEventArgs


The SchedulerControl.AllowAppointmentConflicts event occurs when the scheduler finds appointments that are in conflict and the SchedulerOptionsCustomization.AllowAppointmentConflicts property is set to Custom. The AppointmentConflictEventArgs class introduces the AppointmentConflictEventArgs.Conflicts property which returns the collection of appointments that are considered to be in conflict with the current appointment, and the AppointmentConflictEventArgs.Interval property that specifies the time interval of the appointment. The processed appointment is identified by the AppointmentEventArgs.Appointment property.

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


This example demonstrates how to manually determine whether there are appointment conflicts or not in some particular situations. If you're not satisfied with the automatic conflicts determination of the XtraScheduler (when appointments are considered to conflict if they have the same resource and their time intervals intersect), you can set the SchedulerOptionsCustomization.AllowAppointmentConflicts property to Custom and handle the SchedulerControl.AllowAppointmentConflicts event to perform your own conflict determination.

In the following example it's assumed that an appointment is a lecture conducted by a teacher in a classroom, and several groups of students may be present at the same lecture at the same time. Two appointments are consider to be in conflict in the following situations.

  • Two different lecturers are scheduled to conduct a lecture at the same time in the same room.
  • The same lecturer is scheduled to conduct different lectures at the same time in different rooms.
  • The same group is scheduled at the same time in different rooms.
using DevExpress.XtraScheduler;
// ...

// Appointment = Lecture
// Resource = Room
// appointment.CustomFields["Teacher"] = Teacher
// appointment.CustomFields["Group"] = Group of Students

// Start of the AllowAppointmentConflicts event handler.
// ==================================================

private void schedulerControl1_AllowAppointmentConflicts(object sender, 
    AppointmentConflictEventArgs e) {
   Appointment currentLecture = e.Appointment;
   object roomId = currentLecture.ResourceId;
   string teacher = GetTeacher(currentLecture);
   string group = GetGroup(currentLecture);
   DateTime start = currentLecture.Start;
   TimeSpan duration = currentLecture.Duration;

   // e.Conflicts contains all the lectures held at the same time.
   // All of them the SchedulerControl considers to be conflicting.
   AppointmentBaseCollection lecturesInTheSameTime = e.Conflicts;

   AppointmentBaseCollection conflictedLectures = new AppointmentBaseCollection();
   AppointmentBaseCollection lecturesInDifferentRoomWithDifferentTeacher = 
    new AppointmentBaseCollection();
   ArrayList groupsInDifferentRoomWithDifferentTeacher = new ArrayList();
   ArrayList groups = new ArrayList();

   int count = lecturesInTheSameTime.Count;
   for (int i = 0; i < count; i++) {
      Appointment lecture = lecturesInTheSameTime[i];

      // Check if the lecture is in the same room.
      if (Object.Equals(lecture.ResourceId, roomId)) { 
         // Check if the lecture is by the same teacher.
         if (String.Compare(teacher, GetTeacher(lecture), true) == 0) { 
            if (lecture.Start != start || lecture.Duration != duration) {
               // Conflict! Lecture with a bad time frame.
            else {
               // No conflict!
         // Lecture by a different teacher.
         else { 
            // Conflict! Lecture by a different teacher in the same room.
      // Lecture in a different room.
      else { 
         // Lecture by the same teacher.
         if (String.Compare(teacher, GetTeacher(lecture), true) == 0) { 
            // Conflict! Lecture of the same teacher in the different room.
         // Lecture by a different teacher.
         else { 
            // No conflict! Lecture by a different teacher in a different room.

   // Search for the groups which should be in different rooms at the same time.
   count = groups.Count;
   for (int i = 0; i < count; i++) {
      int conflictIndex = groupsInDifferentRoomWithDifferentTeacher.IndexOf(groups[i]);
      if (conflictIndex >= 0)

   // If the conflictedLectures will contain no lectures after this event has occured, 
   // then e.Conflicts will be empty and this will indicate that there are no conflicts.

// End of the AllowAppointmentConflicts event handler.
// ==================================================

// Additional functions.
// ====================
// Determines the teacher for the specified lecture.
string GetTeacher(Appointment lecture) {
   object teacher = lecture.CustomFields["Teacher"];
   if (teacher == null)
      return String.Empty;

   return teacher.ToString();
// Determines the group for the specified lecture.
string GetGroup(Appointment lecture) {
   object group = lecture.CustomFields["Group"];
   if (group == null)
      return String.Empty;

   return group.ToString();


See Also