Back to Devexpress

SchedulerDataStorage.FilterResource Event

windowsforms-devexpress-dot-xtrascheduler-dot-schedulerdatastorage-c258856d.md

latest4.0 KB
Original Source

SchedulerDataStorage.FilterResource Event

Hides specific resources in the Scheduler control.

Namespace : DevExpress.XtraScheduler

Assembly : DevExpress.XtraScheduler.v25.2.dll

NuGet Package : DevExpress.Win.Scheduler

Declaration

csharp
public event PersistentObjectCancelEventHandler FilterResource
vb
Public Event FilterResource As PersistentObjectCancelEventHandler

Event Data

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

PropertyDescription
CancelGets or sets whether to cancel the operation.
ObjectGets the persistent object (appointment, resource or appointment dependency) for which the event occurs. Inherited from PersistentObjectEventArgs.

Remarks

Handle the FilterResource event to hide specific resources in the Scheduler control. This event fires each time when the layout of the Scheduler control changes (on resizing the control, adding a new appointment, modifying existing appointments, etc.) You can also force the layout update by calling the SchedulerViewBase.LayoutChanged method.

The FilterResource event is raised for each resource in the Resources storage. If the PersistentObjectCancelEventArgs.Cancel parameter is set to true for the currently processed resource, then the Scheduler control does not display this resource. Specifically, the resource is hidden when appointments are grouped by resources (see the SchedulerControl.GroupType topic).

Important

Subscribe to the FilterResource event before storage initialization (before the PersistentObjectStorage<T>.DataSource is assigned), otherwise the filter is not applied.

Example

The example below shows how to filter resources in a scheduler. The filter shows the first three resources only.

csharp
using DevExpress.XtraScheduler;

private void schedulerDataStorage1_FilterResource(object sender, PersistentObjectCancelEventArgs e) {
    SchedulerDataStorage storage = (SchedulerDataStorage) sender;
    Resource res = (Resource) e.Object;
    // Shows the first three resources in the collection.
    e.Cancel = storage.Resources.Items.IndexOf(res) > 2 ;
}
vb
Imports DevExpress.XtraScheduler

Private Sub schedulerDataStorage1_FilterResource(ByVal sender As Object, ByVal e As PersistentObjectCancelEventArgs)
    Dim storage As SchedulerDataStorage = CType(sender, SchedulerDataStorage)
    Dim res As Resource = CType(e.Object, Resource)
    ' Shows the first three resources in the collection.
    e.Cancel = storage.Resources.Items.IndexOf(res) > 2
End Sub

See Also

FilterAppointment

SchedulerDataStorage Class

SchedulerDataStorage Members

DevExpress.XtraScheduler Namespace