Back to Devexpress

TimeRegion.Recurrence Property

windowsforms-devexpress-dot-xtrascheduler-dot-timeregion-cd2567f8.md

latest3.8 KB
Original Source

TimeRegion.Recurrence Property

Provides access to settings that specify the rule (pattern), according to which this region reoccurs.

Namespace : DevExpress.XtraScheduler

Assembly : DevExpress.XtraScheduler.v25.2.dll

NuGet Package : DevExpress.Win.Scheduler

Declaration

csharp
public RecurrenceInfo Recurrence { get; set; }
vb
Public Property Recurrence As RecurrenceInfo

Property Value

TypeDescription
RecurrenceInfo

Stores recurrence settings.

|

Remarks

The code below illustrates how to create two recurring time regions.

csharp
DateTime baseDate = DateTimeHelper.GetStartOfWeek(DateTime.Today);
baseDate = baseDate.AddDays(-15);

//Region #1 - 1p.m. to 2p.m., repeats every work day
TimeRegion timeRegion1 = new TimeRegion();
timeRegion1.Start = baseDate.AddHours(13);
timeRegion1.End = baseDate.AddHours(14);
timeRegion1.Editable = false;
timeRegion1.Recurrence = new RecurrenceInfo();
timeRegion1.Recurrence.Start = timeRegion1.Start;
timeRegion1.Recurrence.Type = RecurrenceType.Weekly;
timeRegion1.Recurrence.WeekDays = WeekDays.WorkDays;
scheduler.TimeRegions.Add(timeRegion1);

//Region #2 - all day long, repeats every weekend
TimeRegion timeRegion2 = new TimeRegion();
timeRegion2.Start = baseDate;
timeRegion2.End = baseDate.AddDays(1);
timeRegion2.Editable = false;
timeRegion2.Recurrence = new RecurrenceInfo();
timeRegion2.Recurrence.Start = timeRegion2.Start;
timeRegion2.Recurrence.Type = RecurrenceType.Weekly;
timeRegion2.Recurrence.WeekDays = WeekDays.WeekendDays;
scheduler.TimeRegions.Add(timeRegion2);
vb
Dim baseDate As Date = DateTimeHelper.GetStartOfWeek(Date.Today)
baseDate = baseDate.AddDays(-15)

'Region #1 - 1p.m. to 2p.m., repeats every work day
Dim timeRegion1 As New TimeRegion()
timeRegion1.Start = baseDate.AddHours(13)
timeRegion1.End = baseDate.AddHours(14)
timeRegion1.Editable = False
timeRegion1.Recurrence = New RecurrenceInfo()
timeRegion1.Recurrence.Start = timeRegion1.Start
timeRegion1.Recurrence.Type = RecurrenceType.Weekly
timeRegion1.Recurrence.WeekDays = WeekDays.WorkDays
scheduler.TimeRegions.Add(timeRegion1)

'Region #2 - all day long, repeats every weekend
Dim timeRegion2 As New TimeRegion()
timeRegion2.Start = baseDate
timeRegion2.End = baseDate.AddDays(1)
timeRegion2.Editable = False
timeRegion2.Recurrence = New RecurrenceInfo()
timeRegion2.Recurrence.Start = timeRegion2.Start
timeRegion2.Recurrence.Type = RecurrenceType.Weekly
timeRegion2.Recurrence.WeekDays = WeekDays.WeekendDays
scheduler.TimeRegions.Add(timeRegion2)

You can add dates to the TimeRegion.ExceptionDates collection to remove individual time region occurences. For instance, the following code removes the timeRegion1 illustrated in the sample above from the March 21, 2019:

csharp
//Time must match the region's Start time
timeRegion1.ExceptionDates.Add(new DateTime(2019, 3, 21, 13, 0, 0));
vb
'Time must match the region's Start time
timeRegion1.ExceptionDates.Add(New Date(2019, 3, 21, 13, 0, 0))

See Also

TimeRegion Class

TimeRegion Members

DevExpress.XtraScheduler Namespace