Skip to main content

SchedulerViewBase.SetSelection(TimeInterval, Resource) Method

Selects time cells which encompass the specified time interval.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v23.2.dll

NuGet Package: DevExpress.Win.Scheduler

Declaration

public virtual void SetSelection(
    TimeInterval interval,
    Resource resource
)

Parameters

Name Type Description
interval TimeInterval

A TimeInterval object that specifies the time interval to select.

resource Resource

A Resource object that specifies to which resource the specified time interval belongs.

Remarks

Use the SetSelection method to select time cells within the view. The Resource object defined via the resource parameter specifies the resource associated with the selected cells when the view is grouped with the SchedulerViewBase.GroupType set to SchedulerGroupType.Resource or SchedulerGroupType.Date values. For a scheduler without resources, specify the ResourceEmpty.Resource value as the resource parameter.

Note

Calling the SetSelection method raises the SchedulerControl.SelectionChanged event.

Example

This code selects time cells in the range which starts from the current time and lasts for 2 h 40 min. The selection snaps to the nearest time cell boundaries. Only cells in the column which belong to the second visible resource are selected. The SchedulerControl.CustomDrawTimeCell event is handled to highlight the selection with a specific color.

scheduler.CustomDrawTimeCell += scheduler_CustomDrawTimeCell_2;
//scheduler.Storage.Appointments.Clear();
scheduler.ActiveView.GroupType = SchedulerGroupType.Resource;
scheduler.ActiveView.SetSelection(new TimeInterval(DateTime.Now, new TimeSpan(2, 40, 0)), scheduler.ActiveView.GetResources()[1]);

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SetSelection(TimeInterval, Resource) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also