Back to Devexpress

GanttControl.WorkWeek Property

windowsforms-devexpress-dot-xtragantt-dot-ganttcontrol-a64c13fc.md

latest3.4 KB
Original Source

GanttControl.WorkWeek Property

Provides access to a rule that specifies work hours for a workweek.

Namespace : DevExpress.XtraGantt

Assembly : DevExpress.XtraGantt.v25.2.dll

NuGet Package : DevExpress.Win.Gantt

Declaration

csharp
[DXCategory("Behavior")]
public WorkWeekRule WorkWeek { get; }
vb
<DXCategory("Behavior")>
Public ReadOnly Property WorkWeek As WorkWeekRule

Property Value

TypeDescription
WorkWeekRule

An object that specifies work hours for a workweek.

|

Remarks

The WorkWeek property provides access to the workweek schedule. The default workweek is from Monday to Friday. Work hours are 8:00 to 17:00 with a break between 12:00 and 13:00.

To customize the schedule in the Visual Studio Designer, click Edit Work Week Schedule in the control’s smart tag menu (or click Run Designer and navigate to the Work Week Schedule section). You can specify the schedule for each day of the week.

The upper bound is not included in the working hours. For example, if the working time is until noon, 12:00 PM is not working time, but the time a moment (tick) earlier, remains the working time.

Note

The specified work hours are automatically sorted. If the specified work hours overlap each other, they are automatically merged.

Example

The code below shows how to change work hours for Wednesday and make Monday a day off.

csharp
// Add Monday as a non-work day.
ganttControl1.WorkWeek.Add(new WorkDayOfWeek(DayOfWeek.Monday, true));

// Work hours for Wednesday are 9:00 to 17:30
// with a break between 12:00 and 13:30.
WorkTime wednesdayMorningWorkTime = new WorkTime(9, 12);
WorkTime wednesdayAfternoonWorkTime = new WorkTime(new TimeSpan(13, 30, 00), new TimeSpan(17, 30, 00));
WorkDayOfWeek wednesday = new WorkDayOfWeek(DayOfWeek.Wednesday, wednesdayMorningWorkTime, wednesdayAfternoonWorkTime);
ganttControl1.WorkWeek.Add(wednesday);
vb
' Add Monday as a non-work day.
ganttControl1.WorkWeek.Add(New WorkDayOfWeek(DayOfWeek.Monday, True))

' Work hours for Wednesday are 9:00 to 17:30
' with a break between 12:00 and 13:30.
Dim wednesdayMorningWorkTime As New WorkTime(9, 12)
Dim wednesdayAfternoonWorkTime As New WorkTime(New TimeSpan(13, 30, 00), New TimeSpan(17, 30, 00))
Dim wednesday As New WorkDayOfWeek(DayOfWeek.Wednesday, wednesdayMorningWorkTime, wednesdayAfternoonWorkTime)
ganttControl1.WorkWeek.Add(wednesday)

See Also

Workweek Schedule and Exceptions

Exceptions

GanttControl Class

GanttControl Members

DevExpress.XtraGantt Namespace