Back to Devexpress

SchedulerControl.AppointmentDrop Event

windowsforms-devexpress-dot-xtrascheduler-dot-schedulercontrol-fdc23257.md

latest7.4 KB
Original Source

SchedulerControl.AppointmentDrop Event

Fires when you drop the appointment dragged with the mouse.

Namespace : DevExpress.XtraScheduler

Assembly : DevExpress.XtraScheduler.v25.2.dll

NuGet Package : DevExpress.Win.Scheduler

Declaration

csharp
public event AppointmentDragEventHandler AppointmentDrop
vb
Public Event AppointmentDrop As AppointmentDragEventHandler

Event Data

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

PropertyDescription
AdditionalAppointmentsProvides access to the collection of the additional dragged appointments.
AllowAllGets or sets whether the user can drag the appointment along time cells.
AllowThisAppointmentGets or sets whether the drag operation is allowed for a specific appointment when the user is dragging multiple appointments at the same time.
CopyEffectIndicates whether the drop effect in a drag-and-drop appointment operation is Copy.
EditedAppointmentGets the appointment being modified in the drag-and-drop event.
ForceUpdateFromStorageGets or sets whether the View is forced to query appointments from the storage.
HitIntervalGets the time interval represented by the time cell to which an appointment was dragged.
HitResourceGets the resource to which an appointment was dragged.
NewAppointmentResourceIdsGets or sets the IDs of resources for a new appointment.
SourceAppointmentGets 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.

csharp
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;
}
vb
Private Sub schedulerControl1_AppointmentDrop(ByVal sender As Object, ByVal e As AppointmentDragEventArgs)
    If e.EditedAppointment.IsRecurring Then
        e.Allow = DropRecurringAppointment (e.SourceAppointment.RecurrencePattern, e.EditedAppointment.Start)
    Else
        e.Allow = DropNormalAppointment(e.EditedAppointment, e.EditedAppointment.Start,e.SourceAppointment.Start)
    End If
End Sub
Private Function DropNormalAppointment(ByVal appointment As Appointment, ByVal newStart As DateTime, ByVal srcStart As DateTime) As Boolean
    Dim createEventMsg As String = "Creating an event on {0:D} at {1:t}."
    Dim moveEventMsg As String = "Moving the event " & Constants.vbCrLf & "scheduled on {0:D} at {1:T}" & Constants.vbCrLf & "to {2:dddd, dd MMM yyyy HH:mm:ss }."
    Dim msg As String = If((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) = System.Windows.Forms.DialogResult.Yes Then
        appointment.Subject += Constants.vbCrLf & "datetime modified"
        Return True
   End If
    Return False
End Function
Private Function DropRecurringAppointment(ByVal pattern As Appointment, ByVal newStart As DateTime) As Boolean
    Dim result As DialogResult = MessageBox.Show("Should the entire series follow the appointment?", "Confirm the action", MessageBoxButtons.YesNoCancel)
    If result = System.Windows.Forms.DialogResult.Yes Then
        pattern.DeleteExceptions()
        pattern.RecurrenceInfo.Start = newStart
    Else
        If result = System.Windows.Forms.DialogResult.No Then
            Return True
        End If
    End If

    Return False
End Function

See Also

SchedulerControl Class

SchedulerControl Members

DevExpress.XtraScheduler Namespace