How to: Create Appointments with Various Recurrence Types Programmatically (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 document demonstrates how recurring appointments with different periodicity and number of occurrences can be created in code. Many examples are provided to help you in specifying complex periodical conditions.
Perform the following simple steps. First, create a new appointment that will serves as a pattern for recurring appointments. Then, modify its recurrence information as required via the Appointment.RecurrenceInfo property. Note than you can specify only one type of recurrence - minutely, hourly, daily, weekly, monthly, or yearly. Finally, add the created recurrence pattern to the storage.
1. Create a Pattern
Use the following code to create a pattern for recurring appointments starting at 9 AM and finishing at 9:15. So the first appointment in a series will start at 9 AM and will last for 15 minutes.
Appointment apt = schedulerControl1.Storage.CreateAppointment(AppointmentType.Pattern); apt.Start = DateTime.Today.AddHours(9); apt.End = apt.Start.AddMinutes(15); apt.Subject = "My Subject"; apt.Location = "My Location"; apt.Description = "My Description";
2. Specify the Recurrence Information
To specify the recurrence information, use the Appointment.RecurrenceInfo property providing access to the RecurrenceInfo instance. It is created automatically for an appointment of the AppointmentType.Pattern type.
Select one of available recurrence types and set all required recurrence attributes. For example, refer to one of the following documents.
3. The Final Step
And finally, add the created recurrence pattern to the storage.