Skip to main content

ASPxScheduler.QueryWorkTime Event

Occurs when the scheduler’s view calculates the work time interval for the specific resource.

Namespace: DevExpress.Web.ASPxScheduler

Assembly: DevExpress.Web.ASPxScheduler.v23.2.dll

NuGet Package: DevExpress.Web.Scheduler

Declaration

public event QueryWorkTimeEventHandler QueryWorkTime

Event Data

The QueryWorkTime event's data class is QueryWorkTimeEventArgs. The following properties provide information specific to this event:

Property Description
Interval Gets the time interval for which the working time is queried.
Resource Gets the resource for which the working time interval is queried.
WorkTime Gets or sets the working time interval.
WorkTimes Provides access to the collection of work times specified for a single day.

Remarks

Handle this event for a particular scheduler’s View to adjust the resource’s work time interval.

Note

When different work time intervals are specified in the ASPxScheduler.QueryWorkTime event handler, the DayView.ShowWorkTimeOnly option has no effect.

Example: How to specify several working time intervals for different days of week

In this example, the QueryWorkTime event is handled to set up working time intervals for different days of week. The WorkTimes property contains a collection of work time intervals for a particular day.

dx:ASPxScheduler ID="ASPxScheduler1" runat="server" OnQueryWorkTime="ASPxScheduler1_QueryWorkTime" />
protected void Page_Load(object sender, EventArgs e) {
    ASPxScheduler1.ActiveViewType = SchedulerViewType.WorkWeek;
    ASPxScheduler1.WorkWeekView.WorkTime =
        new TimeOfDayInterval(new TimeSpan(8, 0, 0), new TimeSpan(18, 0, 0));
    ASPxScheduler1.WorkWeekView.ShowWorkTimeOnly = true;
}
protected void ASPxScheduler1_QueryWorkTime(object sender, QueryWorkTimeEventArgs e) {
    switch(e.Interval.Start.DayOfWeek) {
        case DayOfWeek.Monday:
            e.WorkTimes.Add(new TimeOfDayInterval(TimeSpan.FromHours(8), TimeSpan.FromHours(12)));
            e.WorkTimes.Add(new TimeOfDayInterval(TimeSpan.FromHours(13), TimeSpan.FromHours(17)));
            break;
        case DayOfWeek.Friday:
            e.WorkTimes.Add(new TimeOfDayInterval(TimeSpan.FromHours(10), TimeSpan.FromHours(14)));
            break;
        default:
            e.WorkTimes.Add(new TimeOfDayInterval(TimeSpan.FromHours(9), TimeSpan.FromHours(13)));
            e.WorkTimes.Add(new TimeOfDayInterval(TimeSpan.FromHours(14), TimeSpan.FromHours(18)));
            break;
    }
}

Custom Work Times

See Also