windowsforms-devexpress-dot-xtrascheduler-dot-schedulercontrol-47b9f070.md
Allows you to sort appointments in any custom order.
Namespace : DevExpress.XtraScheduler
Assembly : DevExpress.XtraScheduler.v25.2.dll
NuGet Package : DevExpress.Win.Scheduler
public event CustomAppointmentSortEventHandler CustomAppointmentSort
Public Event CustomAppointmentSort As CustomAppointmentSortEventHandler
The CustomAppointmentSort event's data class is DevExpress.XtraScheduler.CustomAppointmentSortEventArgs.
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.
Read these parameters to compare the appointments, and specify the integer e.Result property depending on which of the two appointments should go first.
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.
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);
}
Private Sub SchedulerControl1_CustomAppointmentSort(ByVal sender As Object, ByVal e As CustomAppointmentSortEventArgs)
Dim apt1 As Appointment = e.AppointmentLayoutInfo1.Appointment
Dim apt2 As Appointment = e.AppointmentLayoutInfo2.Appointment
'compare by statuses
e.Result = CInt(Math.Truncate(apt1.StatusKey)).CompareTo(CInt(Math.Truncate(apt2.StatusKey)))
If e.Result <> 0 Then
Return
End If
'if statuses are the same, compare by dates
e.Result = apt1.Start.CompareTo(apt2.Start)
If e.Result <> 0 Then
Return
End If
e.Result = -apt1.End.CompareTo(apt2.End)
End Sub
See Also