AppointmentDragEventArgs.AdditionalAppointments Property

Provides access to the collection of the additional dragged appointments.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v20.1.Core.dll

Declaration

public AppointmentBaseCollection AdditionalAppointments { get; }
Public ReadOnly Property AdditionalAppointments As AppointmentBaseCollection

Property Value

Type Description
AppointmentBaseCollection

An AppointmentBaseCollection containing appointments dragged along with the initial appointments.

Remarks

Handle the SchedulerControl.AdditionalAppointmentsDrag event to populate the AdditionalAppointments collection with the appointments which should be dragged along with the appointments initially dragged by the end-user.

Examples

private void SchedulerControl_AppointmentDrag(object sender, AppointmentDragEventArgs e) {
    // Find a special appointment among visible appointments.
    AppointmentBaseCollection visbileApts = schedulerControl1.ActiveView.GetAppointments();
    Appointment apt = visbileApts.Find(item => (item.Subject == "Finalize" && item.ResourceId.Equals(e.HitResource.Id)));
    if (apt == null) {
        e.AdditionalAppointments.Clear();
    }
    else {
        if (e.SourceAppointment != apt) {
            // If the dragged appointment overlaps with the special appointment,
            // add the special appointment to the AdditionalAppointments collection
            // to drag along with the initial appointment.
            // The AdditionalAppointmentsDrag event will occur.
            if (e.EditedAppointment.End > apt.Start)
                e.AdditionalAppointments.Add(apt);
            else
                e.AdditionalAppointments.Clear();
        }
    }
}

private void SchedulerControl1_AdditionalAppointmentsDrag(object sender, AdditionalAppointmentsDragEventArgs e) {
    if (e.AdditionalAppointmentInfos.Count <= 0)
        return;
    AppointmentDragInfo aptInfo = e.AdditionalAppointmentInfos[0];
    // If the end of the main dragged appointment becomes greater than the start of the special appointment,
    // set the start of the special appointment being dragged to the end of the main dragged appointment.
    // It prevents overlapping appointments.
    if (e.PrimaryAppointmentInfos[0].EditedAppointment.End > aptInfo.SourceAppointment.Start)
        aptInfo.EditedAppointment.Start = e.PrimaryAppointmentInfos[0].EditedAppointment.End;
}
See Also