Skip to main content

SchedulerStorage.AppointmentInserting Event

Allows you to cancel the insertion of an appointment.

Namespace: DevExpress.Xpf.Scheduler

Assembly: DevExpress.Xpf.Scheduler.v14.2.dll

#Declaration

public event PersistentObjectCancelEventHandler AppointmentInserting

#Event Data

The AppointmentInserting event's handler receives an argument of the PersistentObjectCancelEventArgs type. The following properties provide information specific to this event:

Property Description
Cancel Gets or sets whether the operation performed on the processed event should be canceled.
Object Gets the persistent object for which the event was raised. Inherited from PersistentObjectEventArgs.

#Remarks

The AppointmentInserting event is raised before an appointment is added to the AppointmentCollection collection, and allows you to perform any custom actions before an appointment is inserted or cancel the operation. The event parameter's PersistentObjectEventArgs.Object property allows the processed appointment to be identified. To prevent it from being added, set the PersistentObjectCancelEventArgs.Cancel property to true.

NOTE

Do not modify the appointment's data source or data binding within this event handler. It results in the current appointment being disposed of, and consequently, an unhandled exception occurs.

NOTE

The SchedulerStorage.AppointmentsInserted event is raised after the AppointmentInserting event, when appointments are already in the storage, and are saved to the external data source (if any). At the moment, you cannot prevent them from being saved.

#Examples

This example demonstrates how to use the SchedulerStorage.AppointmentInserting event to add a timestamp to the created appointment.

To validate appointment insertion, you can get the properties of the appointment being inserted by casting the e.Object parameter to the Appointment type.

using System;
using DevExpress.XtraScheduler;
// ...

private void SchedulerStorage_AppointmentInserting(object sender, PersistentObjectCancelEventArgs e) {
    Appointment apt = e.Object as Appointment;
    if (apt != null) {
        apt.Description += "\r\ncreated at " + DateTime.Now.ToString();
    }
}
See Also