Skip to main content

Applying The Recurrence Pattern

  • 3 minutes to read

Some user events are recurring – they occur repeatedly (on a regular basis). The following elements define how the recurrence is applied to the recurring user event:

Both of these elements compose the so-called Recurrence pattern, which defines when the user event reoccurs.

The Range of recurrence element defines the time boundaries/limits of a recurrence. Refer to the following usage scenarios for this element:

The following example applies Recurrence pattern and Range of recurrence patterns to create a recurring user event:

// ...
with DBStorage.CreateEvent do
begin
  ResourceID := 1; // assign the newly created user event to the Lesli Gritts resource. For how to set up a resource in bound mode see the Bound Mode topic
  Caption := 'Appointment with a doctor'; // specify the subject
  Start := Date + 10 * HourToTime; // the start time of the user event (the HourToTime constant is defined in the cxSchedulerUtils unit) 
  Duration := 30 * MinuteToTime; // the duration of the user event (the MinuteToTime constant is defined in the cxSchedulerUtils unit)
  State := tlsOutOfOffice; // the availability status is "out of office"
  EventType := etPattern; // start the series of the occurrences
  RecurrenceInfo.Count := 3; // end after three occurrences
  RecurrenceInfo.Recurrence := cxreDaily; // the daily basis
  RecurrenceInfo.DayType := cxdtWeekDay;     
  RecurrenceInfo.Periodicity := 1; // repeat every weekday
  Post; // synchronize with storage
end;

This is the code execution result:

Note

the output shown is produced when the scheduler’s LookAndFeel.NativeStyle property is set to False, the lfFlat flag on the LookAndFeel.Kind property is active, two resources are defined and the scheduler’s OptionsView.GroupingKind property is set to gkByDate.