The requested page is not available for the requested platform. You are viewing the content for Default platform.

Dashboard.ItemCollectionChanged Event

Occurs after the collection of dashboard items has been changed.

Namespace: DevExpress.DashboardCommon

Assembly: DevExpress.Dashboard.v19.2.Core.dll

Declaration

public event EventHandler<NotifyingCollectionChangedEventArgs<DashboardItem>> ItemCollectionChanged
Public Event ItemCollectionChanged As EventHandler(Of NotifyingCollectionChangedEventArgs(Of DashboardItem))

Event Data

The ItemCollectionChanged event handler receives an argument of the DevExpress.DataAccess.NotifyingCollectionChangedEventArgs<DevExpress.DashboardCommon.DashboardItem> type. The following properties provide information specific to this event.

Property Description
AddedItems Gets items added to the NotifyingCollection<T>.
RemovedItems Gets items removed from the NotifyingCollection<T>.

Remarks

The ItemCollectionChanged event is raised after dashboard items are added to or removed from the Dashboard.Items collection.

Use the event parameter's NotifyingCollectionChangedEventArgs`1.AddedItems and NotifyingCollectionChangedEventArgs`1.RemovedItems properties to determine which dashboard items have been added or removed, respectively.

Note

The complete sample project How to notify when a dashboard item is added, removed or duplicated is available in the DevExpress Examples repository.

The following code logs the DashboardItem information when a DashboardItem is added, deleted or duplicated.

private void DashboardDesigner1_DashboardLoaded(object sender, DevExpress.DashboardWin.DashboardLoadedEventArgs e)
{
    e.Dashboard.ItemCollectionChanged += Dashboard_ItemCollectionChanged;
}

private void Dashboard_ItemCollectionChanged(object sender, NotifyingCollectionChangedEventArgs<DashboardItem> e)
{
    Dashboard dBoard = sender as Dashboard;
    if (e.AddedItems.Count > 0)
    {
        if (e.AddedItems.Count == 1 && dBoard.Items.Count(i => i.Name == e.AddedItems[0].Name) > 1)
            AddToLog("Duplicated", e.AddedItems);
        else
            AddToLog("Added", e.AddedItems);
    }
    if (e.RemovedItems.Count > 0)
    {
        AddToLog("Removed", e.RemovedItems);
    }
}
See Also