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

SchedulerControl.CustomAppointmentSort Event

Allows you to sort appointments in any custom order.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v19.1.dll

Declaration

public event CustomAppointmentSortEventHandler CustomAppointmentSort
Public Event CustomAppointmentSort As CustomAppointmentSortEventHandler

Event Data

The CustomAppointmentSort event's data class is DevExpress.XtraScheduler.CustomAppointmentSortEventArgs.

Remarks

The CustomAppointmentSort event raises for each encountered appointment, and compares it with an appointment that will be placed after the currently processed appointment if you do not implement a custom sort algorithm.

  • e.AppointmentLayoutInfo1 parameter - stores information about the appointment that will go first should you leave the default sort order. The returned IAppointmentLayoutInfo object allows you to obtain the appointment itself, its related resource, and start/end dates.
  • e.AppointmentLayoutInfo2 parameter - stores information about the appointment that will go after the first appointment if you leave the default sort order.

Read these parameters to compare the appointments, and specify the integer e.Result property depending on which of the two appointments should go first.

  • Set the e.Result to any negative value if the appointment related to the e.AppointmentLayoutInfo1 parameter should go first.
  • Set the e.Result to any positive value if the appointment related to the e.AppointmentLayoutInfo2 parameter should go first.
  • Set the e.Result to 0 if both appoitnments are equal and the Scheduler should utilize default sort mechanism to arrange them.

The Timeline View demo module illustrates how to sort appointments by their Statuses: appointments with the "Out of Office" status are placed after appointments with no statuses. Note that you can sort appointments regardless of whether they have been grouped (see SchedulerControl.CustomAppointmentGroup) or not.

custom_sort

void SchedulerControl1_CustomAppointmentSort(object sender, CustomAppointmentSortEventArgs e) {
    Appointment apt1 = e.AppointmentLayoutInfo1.Appointment;
    Appointment apt2 = e.AppointmentLayoutInfo2.Appointment;
    //compare by statuses
    e.Result = ((int)apt1.StatusKey).CompareTo((int)apt2.StatusKey);
    if (e.Result != 0)
        return;
    //if statuses are the same, compare by dates
    e.Result = apt1.Start.CompareTo(apt2.Start);
    if (e.Result != 0)
        return;
    e.Result = -apt1.End.CompareTo(apt2.End);
}
See Also