Skip to main content

Appointment.Copy() Method

Creates a copy of the current Appointment object.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v14.2.Core.dll

#Declaration

public Appointment Copy()

#Returns

Type Description
Appointment

An Appointment object which is a copy of the current object.

#Remarks

The Copy method creates a new instance of the Appointment class and copies the properties of the current appointment object to it. Note, that the type of the created appointment will always be Normal, except when the type of appointment being copied is Pattern, in which case the created appointment will also be the Pattern type.

#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