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

SchedulerControl.AppointmentDrop Event

Fires when you drop the appointment dragged with the mouse.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v18.2.dll

Declaration

public event AppointmentDragEventHandler AppointmentDrop

Event Data

The AppointmentDrop 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

Handle the AppointmentDrop event to decide what to do with an appointment before dropping it. You have access to the former appointment before dragging, to the time interval where the appointment is being dropped and the resource associated with a new appointment location. The AppointmentDragEventArgs.NewAppointmentResourceIds property can be used for assignment of resources to a relocated appointment.

Example

This example handles the SchedulerControl.AppointmentDrop event to delete the occurrences of the recurring appointment and specify new Appointment.Start and Appointment.End properties of the Appointment.RecurrencePattern.

AppointmentDrop

private void schedulerControl1_AppointmentDrop(object sender, AppointmentDragEventArgs e) {
    if (e.EditedAppointment.IsRecurring)
        e.Allow = DropRecurringAppointment (e.SourceAppointment.RecurrencePattern, e.EditedAppointment.Start);
    else
        e.Allow = DropNormalAppointment(e.EditedAppointment, e.EditedAppointment.Start,e.SourceAppointment.Start);
}
private bool DropNormalAppointment(Appointment appointment, DateTime newStart,DateTime srcStart ) {
    string createEventMsg = "Creating an event on {0:D} at {1:t}.";
    string moveEventMsg = "Moving the event \r\nscheduled on {0:D} at {1:T}\r\nto {2:dddd, dd MMM yyyy HH:mm:ss }.";
    string msg = (srcStart == DateTime.MinValue) ? String.Format(createEventMsg, newStart.Date,newStart.TimeOfDay) :
        String.Format(moveEventMsg, srcStart.Date, srcStart.TimeOfDay, newStart);
   if (MessageBox.Show(msg + " Proceed?", "Confirm the action", MessageBoxButtons.YesNo) == DialogResult.Yes) {
        appointment.Subject += "\r\ndatetime modified";
        return true;
    }
    return false;
}
private bool DropRecurringAppointment(Appointment pattern, DateTime newStart) {
    DialogResult result = MessageBox.Show("Should the entire series follow the appointment?", "Confirm the action", MessageBoxButtons.YesNoCancel);
    if (result == DialogResult.Yes) {
        pattern.DeleteExceptions();
        pattern.RecurrenceInfo.Start = newStart;
    } else 
        if (result == DialogResult.No)
            return true;

    return false;
}

The following code snippets (auto-collected from DevExpress Examples) contain references to the AppointmentDrop 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