Skip to main content

AppointmentStorage.Add(Appointment) Method

Appends the specified Appointment object to the collection which can be accessed via the storage's AppointmentStorage.Items property.

Namespace: DevExpress.Xpf.Scheduler

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

#Declaration

public override int Add(
    Appointment obj
)

#Parameters

Name Type Description
obj Appointment

A Appointment object to be appended to the collection.

#Returns

Type Description
Int32

An integer value indicating the position at which the new element has been inserted.

#Remarks

The Add method appends a Appointment object to the end of the appointment collection maintained by the current AppointmentStorage object. This collection can be accessed via the storage's AppointmentStorage.Items property.

To prevent excessive updates when changes to the appointment collection are applied, enclose the code that uses the Add method within calls to the BeginUpdate and EndUpdate methods of the AppointmentStorage obejcts.

NOTE

In order to perform the same action at the level of the appointment collection, the collection's AppointmentCollection.Add method can be used.

#Examples

This example demonstrates how to copy the selected appointments to the following month. A copy of an existing appointment is created via the Appointment.Copy method. After a new appointment has been created, its start time is increased by one month via the Appointment.Start property.

using DevExpress.XtraScheduler;
// ...

// Loop through all the selected appointments.
for(int i = 0; i < schedulerControl1.SelectedAppointments.Count; i++) {
   Appointment apt = schedulerControl1.SelectedAppointments[i];

   // Copy the current appointment.
   Appointment newApt = apt.Copy();

   // Add one month to the new appointment's start time.
   newApt.Start = apt.Start.AddMonths(1);

   // Add the new appointment to the appointment collection.
   schedulerControl1.Storage.AppointmentStorage.Add(newApt); 
}
See Also