dashboard-devexpress-dot-dashboardcommon-dot-dashboard-685bf15e.md
Occurs after the collection of dashboard items has been changed.
Namespace : DevExpress.DashboardCommon
Assembly : DevExpress.Dashboard.v25.2.Core.dll
NuGet Package : DevExpress.Dashboard.Core
public event EventHandler<NotifyingCollectionChangedEventArgs<DashboardItem>> ItemCollectionChanged
Public Event ItemCollectionChanged As EventHandler(Of NotifyingCollectionChangedEventArgs(Of DashboardItem))
The ItemCollectionChanged event's data class is NotifyingCollectionChangedEventArgs<DashboardItem>. 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>. |
The ItemCollectionChanged event is raised after dashboard items are added to or removed from the Dashboard.Items collection.
Use the event parameter’s NotifyingCollectionChangedEventArgs1.AddedItems](/Dashboard/DevExpress.DataAccess.NotifyingCollectionChangedEventArgs-1.AddedItems) and [NotifyingCollectionChangedEventArgs1.RemovedItems properties to determine which dashboard items have been added or removed, respectively.
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);
}
}
Private Sub DashboardDesigner1_DashboardLoaded(ByVal sender As Object, ByVal e As DevExpress.DashboardWin.DashboardLoadedEventArgs)
AddHandler e.Dashboard.ItemCollectionChanged, AddressOf Dashboard_ItemCollectionChanged
End Sub
Private Sub Dashboard_ItemCollectionChanged(ByVal sender As Object, ByVal e As NotifyingCollectionChangedEventArgs(Of DashboardItem))
Dim dBoard As Dashboard = TryCast(sender, Dashboard)
If e.AddedItems.Count > 0 Then
If e.AddedItems.Count = 1 AndAlso dBoard.Items.Count(Function(i) i.Name = e.AddedItems(0).Name) > 1 Then
AddToLog("Duplicated", e.AddedItems)
Else
AddToLog("Added", e.AddedItems)
End If
End If
If e.RemovedItems.Count > 0 Then
AddToLog("Removed", e.RemovedItems)
End If
End Sub
See Also