Dashboard.ItemCollectionChanged Event
Occurs after the collection of dashboard items has been changed.
Namespace: DevExpress.DashboardCommon
Assembly: DevExpress.Dashboard.v24.2.Core.dll
Declaration
public event EventHandler<NotifyingCollectionChangedEventArgs<DashboardItem>> ItemCollectionChanged
Event Data
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>. |
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.
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);
}
}