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

SchedulerStorage.AppointmentInserting Event

Allows you to cancel the insertion of an appointment.

Namespace: DevExpress.Xpf.Scheduler

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

Declaration

public event PersistentObjectCancelEventHandler AppointmentInserting

Event Data

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

Property Description
Cancel Gets or sets whether to cancel the operation.
Object Gets the persistent object (appointment, resource or appointment dependency) for which the event occurs. Inherited from PersistentObjectEventArgs.

Remarks

Important

You are viewing documentation for the legacy WPF Scheduler control. If you’re starting a new project, we strongly recommend that you use a new control declared in the DevExpress.Xpf.Scheduling namespace. If you decide to upgrade an existing project in order to switch to the updated scheduler control, see the Migration Guidelines document.

The AppointmentInserting event is raised before an appointment is added to the AppointmentCollection collection, and allows you to 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.

Example

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 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) {
    IAppointment apt = e.Object as IAppointment;
    if (apt != null) {
        apt.Description += "\r\ncreated at " + DateTime.Now.ToString();
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AppointmentInserting 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