SchedulerControl.AppointmentDrop Event
Fires when you drop the appointment dragged with the mouse.
Namespace: DevExpress.XtraScheduler
Assembly: DevExpress.XtraScheduler.v24.2.dll
Declaration
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. |
AllowAll | Gets or sets whether the user can drag the appointment along time cells. |
AllowThisAppointment | Gets or sets whether the drag operation is allowed for a specific appointment when the user is dragging multiple appointments at the same time. |
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.
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;
}