Skip to main content

OccurrenceCalculator Class

Enables you to calculate the occurrences for a given recurrent appointment.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v23.1.Core.dll

NuGet Package: DevExpress.Scheduler.Core


public abstract class OccurrenceCalculator

The following members return OccurrenceCalculator objects:


Use the OccurrenceCalculator object to calculate occurrences for a predefined time interval, as illustrated in the code sample below.


The calculated appointments do not contain custom fields. This behavior is by design; it increases performance.

If you need to construct the actual recurrence appointment series with both standard and custom appointment fields, then you have to use the AppointmentPatternExpander.Expand method from the DevExpress.XtraScheduler.Native namespace. Create a new AppointmentPatternExpander instance using the Appointment.RecurrencePattern value of your appointment, and then call the Expand method to get the appointments collection.


The following code sample retrieves the recurrence pattern of the first appointment in the scheduler’s collection and replaces all occurrences with appointments of AppointmentType.Normal type. It utilizes the OccurrenceCalculator.CalcOccurrences method to calculate items in the recurrent series.

// Calculate occurrences for the first recurrent series.
Appointment pattern = schedulerStorage1.Appointments.Items.FirstOrDefault(item => item.Type == AppointmentType.Pattern);
if (pattern == null) return;
OccurrenceCalculator calc = OccurrenceCalculator.CreateInstance(pattern.RecurrenceInfo);
TimeInterval processedInterval = new TimeInterval(DateTime.Today, DateTime.Today.AddDays(7));
AppointmentBaseCollection calculatedOccurrences = calc.CalcOccurrences(processedInterval, pattern);

// Create normal appointments in place of occurrences.
for (int i = 0; i < calculatedOccurrences.Count; i++) {
    Appointment resultAppointment = schedulerStorage1.CreateAppointment(AppointmentType.Normal);
    resultAppointment.Subject = String.Format("Occurrence {0} - {1}", calculatedOccurrences[i].Subject, i);
    resultAppointment.Description = calculatedOccurrences[i].Description;
    resultAppointment.Start = calculatedOccurrences[i].Start;
    resultAppointment.End = calculatedOccurrences[i].End;

// Remove the pattern and occurrences.


See Also