Skip to main content
A newer version of this page is available. .

SchedulerControl.AppointmentDrag Event

Occurs when appointment is dragged in the Scheduler control.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v20.2.dll

NuGet Package: DevExpress.Win.Scheduler

Declaration

public event AppointmentDragEventHandler AppointmentDrag

Event Data

The AppointmentDrag event's data class is AppointmentDragEventArgs. The following properties provide information specific to this event:

Property Description
AdditionalAppointments Provides access to the collection of the additional dragged appointments.
Allow Specifies whether the appointment can be dragged along the time cells.
CopyEffect Indicates whether the drop effect in a drag-and-drop appointment operation is Copy.
EditedAppointment Gets the appointment being modified in the drag-and-drop event.
ForceUpdateFromStorage Gets or sets whether the View is forced to query appointments from the storage.
HitInterval Gets the time interval represented by the time cell to which an appointment was dragged.
HitResource Gets the resource to which an appointment was dragged.
NewAppointmentResourceIds Gets or sets the IDs of resources for a new appointment.
SourceAppointment Gets the source appointment in the drag-and-drop event.

Remarks

If a user drags multiple appointments, this event fires for each of them.

The AdditionalAppointments property in event parameters allows you to re-arrange other appointments that were not dragged by a user. In the sample below, if a user is about to schedule the “Start” appointment so that it finishes later in time than the related “Finish” appointment starts, the latter appointment is added to the AdditionalAppointments collection.

DevExpress Scheduler automatically reschedules an appointment when a user drags its related appointment

void SchedulerControl1_AppointmentDrag(object sender, AppointmentDragEventArgs e) {
    if (e.SourceAppointment.Subject == "Start") {
        AppointmentBaseCollection visbileApts = schedulerControl1.ActiveView.GetAppointments();
        Appointment apt = visbileApts.Find(item => item.Subject == "Finish");
        if (apt == null)
            e.AdditionalAppointments.Clear();
        else {
            if (e.SourceAppointment != apt) {
                if (e.EditedAppointment.End > apt.Start)
                    e.AdditionalAppointments.Add(apt);
                else e.AdditionalAppointments.Clear(); 
            }
        }
    }
}

To specify new positions for AdditionalAppointments, handle the SchedulerControl.AppointmentsDrag event.

private void SchedulerControl1_AppointmentsDrag(object sender, DevExpress.XtraScheduler.AppointmentsDragEventArgs e) {
    if (e.AdditionalAppointmentInfos.Count <= 0)
        return;
    AppointmentDragInfo aptInfo = e.AdditionalAppointmentInfos[0];
    if (e.PrimaryAppointmentInfos[0].EditedAppointment.End > aptInfo.SourceAppointment.Start)
        aptInfo.EditedAppointment.Start = e.PrimaryAppointmentInfos[0].EditedAppointment.End;
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the AppointmentDrag event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also