Back to Devexpress

SchedulerControl.SelectedAppointments Property

windowsforms-devexpress-dot-xtrascheduler-dot-schedulercontrol-03436836.md

latest5.5 KB
Original Source

SchedulerControl.SelectedAppointments Property

Provides access to the collection of selected appointments.

Namespace : DevExpress.XtraScheduler

Assembly : DevExpress.XtraScheduler.v25.2.dll

NuGet Package : DevExpress.Win.Scheduler

Declaration

csharp
[Browsable(false)]
public AppointmentBaseCollection SelectedAppointments { get; }
vb
<Browsable(False)>
Public ReadOnly Property SelectedAppointments As AppointmentBaseCollection

Property Value

TypeDescription
AppointmentBaseCollection

An AppointmentBaseCollection descendant which represents the collection of selected appointments.

|

Remarks

The SelectedAppointments property allows you to select specific appointments (by adding them to the returned collection) and get the appointments which are currently selected. The selected appointments can then be processed in a specific manner (for instance, they can be deleted or copied to a different time slot).

Example

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

The following code snippets (auto-collected from DevExpress Examples) contain references to the SelectedAppointments property.

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.

winforms-scheduler-replace-default-command/CS/WindowsFormsApplication1/CustomSchedulerCommandFactoryService.cs#L65

csharp
timeScales.Add(new TimeScaleFixedInterval(SplitAppointmentCommandStep));
    return new SplitAppointmentOperation(SchedulerControl, timeScales, SchedulerControl.SelectedAppointments[0]);
}

winforms-scheduler-create-appointments-on-reminder-alert/CS/ReminderCustomActions/Form1.cs#L118

csharp
Appointment apt = schedulerControl1.SelectedAppointments[0];
if (apt != null && apt.IsRecurring) {

winforms-scheduler-replace-default-command/VB/WindowsFormsApplication1/CustomSchedulerCommandFactoryService.vb#L61

vb
timeScales.Add(New TimeScaleFixedInterval(SplitAppointmentCommandStep))
    Return New SplitAppointmentOperation(SchedulerControl, timeScales, SchedulerControl.SelectedAppointments(0))
End Function

winforms-scheduler-create-appointments-on-reminder-alert/VB/ReminderCustomActions/Form1.vb#L122

vb
Dim apt As Appointment = schedulerControl1.SelectedAppointments(0)
If apt IsNot Nothing AndAlso apt.IsRecurring Then

See Also

SchedulerControl Class

SchedulerControl Members

DevExpress.XtraScheduler Namespace