Back to Devexpress

How to: Obtain Selected Appointments

windowsforms-2286-controls-and-libraries-scheduler-examples-selection-how-to-obtain-selected-appointments.md

latest1.5 KB
Original Source

How to: Obtain Selected Appointments

  • Nov 13, 2018

The following example demonstrates how to copy selected appointments to the next month. A copy of an existing appointment is created via the Appointment.Copy method. When a new appointment is created, its start time is increased by one month.

csharp
using DevExpress.XtraScheduler;
// ...

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

   // Create new appointment using copy operation.
   Appointment newApt = apt.Copy();

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

   // Add new appointment to the appointment collection.
   schedulerControl1.Storage.Appointments.Add(newApt); 
}
vb
Imports DevExpress.XtraScheduler
' ...

' Loop through all the selected appointments.
For i As Integer = 0 To schedulerControl1.SelectedAppointments.Count - 1
   Dim apt As Appointment = schedulerControl1.SelectedAppointments(i)

   ' Create new appointment using copy operation.
   Dim newApt As Appointment = apt.Copy()

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

   ' Add new appointment to the appointment collection.
   schedulerControl1.Storage.Appointments.Add(newApt)
Next i