How to: Create Daily Recurrence

  • 2 minutes to read
<dxsch:SchedulerControl.AppointmentItems>
    <!--Every 3 days. Five occurrences.-->
    <dxsch:AppointmentItem 
        Type="Pattern"
        Start="1/1/2020 13:00:00"
        End="1/1/2020 14:00:00"
        Subject="Every 3 days. Five occurrences."
        RecurrenceInfo="{dxsch:RecurrenceDaily Start='1/1/2020 13:00:00', Interval=3, OccurrenceCount=5}" />
    <!--Every day. Infinite (no end date).-->
    <dxsch:AppointmentItem 
        Type="Pattern"
        Start="1/1/2020 13:00:00"
        End="1/1/2020 14:00:00"
        Subject="Every day. Infinite (no end date)."
        RecurrenceInfo="{dxsch:RecurrenceDaily Start='1/1/2020 13:00:00'}" />
    <!--Every five days. Series for one month.-->
    <dxsch:AppointmentItem 
        Type="Pattern"
        Start="1/1/2020 13:00:00"
        End="1/1/2020 14:00:00"
        Subject="Every five days. Series for one month."
        RecurrenceInfo="{dxsch:RecurrenceDaily Start='1/1/2020 13:00:00', Interval=5, End='2/1/2020'}" />
</dxsch:SchedulerControl.AppointmentItems>
public AppointmentItem CreateAppointmentPattern(string subj, int categoryId) {
    AppointmentItem apt = new AppointmentItem(AppointmentType.Pattern);
    apt.Start = DateTime.Today.AddHours(9);
    apt.End = apt.Start.AddMinutes(5);
    apt.Subject = subj;
    apt.LabelId = categoryId;
    return apt;
}
    // An appointment is set every 3 days. Five occurrences.
    AppointmentItem apt1 = CreateAppointmentPattern("Every 3 days. Five occurrences.", 2);
    apt1.SetRecurrenceInfo(RecurrenceBuilder.Daily(apt1.Start, 5).Interval(3).Build());
    scheduler.AppointmentItems.Add(apt1);

    // An appointment is set every day. Infinite (no end date).
    AppointmentItem apt2 = CreateAppointmentPattern("Every day. Infinite (no end date).", 2);
    apt2.SetRecurrenceInfo(RecurrenceBuilder.Daily(apt2.Start).Build());
    scheduler.AppointmentItems.Add(apt2);

    // An appointment occurs every five days. Appointments are set for one month.
    AppointmentItem apt3 = CreateAppointmentPattern("Every 5 days. Series for one month.", 2);
    apt3.SetRecurrenceInfo(RecurrenceBuilder.Daily(apt3.Start, apt3.Start.AddMonths(1)).Interval(5).Build());
    scheduler.AppointmentItems.Add(apt3);