How to: Create an Appointment for the Currently Selected Time Interval and Resource (legacy)
- 2 minutes to read
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.
This example demonstrates how to create a new appointment for the time interval currently selected in a Scheduler control. Also, shows how to get a resource that contains the selected time interval, and set a resource's Id to the appointment. The selected time interval is accessed via the SchedulerControl.SelectedInterval property, and the selected resource is accessed via the SchedulerControl.SelectedResource property. An appointment is added to the SchedulerStorage.AppointmentStorage collection of the Scheduler's SchedulerControl.Storage.
using DevExpress.Xpf.Scheduler; using DevExpress.XtraScheduler; // ... // Create a new appointment. Appointment apt = new Appointment(); // Set the appointment's time interval to the time interval // currently selected by an end-user. apt.Start = schedulerControl1.SelectedInterval.Start; apt.End = schedulerControl1.SelectedInterval.End; // Set the appointment's resource to the resource, which // contains the currently selected time interval. apt.ResourceId = schedulerControl1.SelectedResource.Id; // Add the new appointment to the appointment collection. schedulerControl1.Storage.AppointmentStorage.Add(apt);