DashboardViewer.DashboardItemBeforeControlDisposed Event

Allows you to access underlying WinForms controls.

Namespace: DevExpress.DashboardWin

Assembly: DevExpress.Dashboard.v18.2.Win.dll

Declaration

public event DashboardItemBeforeControlDisposedEventHandler DashboardItemBeforeControlDisposed
Public Event DashboardItemBeforeControlDisposed As DashboardItemBeforeControlDisposedEventHandler

The DashboardItemBeforeControlDisposed event handler receives an argument of the DashboardItemControlEventArgs type. The following properties provide information specific to this event.

Property Description
CardControl Gets an underlying Card control.
ChartControl Gets an underlying chart control.
DashboardItemName Gets the component name of the dashboard item for which the event was raised.
GaugeControl Gets an underlying gauge control.
GridControl Gets an underlying grid control.
MapControl Gets an underlying map control.
PictureEdit Gets an underlying picture edit control.
PivotGridControl Gets an underlying PivotGridControl.
RichEditControl Gets an underlying RichEdit control.
TreeMapControl Gets an underlying TreeMap control.

Examples

The following example demonstrates how to customize controls used to visualize data within dashboard items at runtime using DashboardViewer's API.

In this example, the following options are changed:

Imports System.Drawing
Imports DevExpress.XtraEditors
Imports DevExpress.DashboardWin
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraCharts
Imports DevExpress.XtraPivotGrid

Namespace Dashboard_ControlAccess
    Partial Public Class Form1
        Inherits XtraForm

        Public Sub New()
            InitializeComponent()
            dashboardViewer1.LoadDashboard("..\..\Data\Dashboard.xml")
        End Sub

        Private Sub dashboardViewer1_DashboardItemControlCreated(ByVal sender As Object, _
                                     ByVal e As DashboardItemControlEventArgs) _
                                 Handles dashboardViewer1.DashboardItemControlCreated
            If e.DashboardItemName = "pivotDashboardItem1" Then
                Dim pivotGridControl As PivotGridControl = e.PivotGridControl
                AddHandler pivotGridControl.CustomCellValue, AddressOf pivotGridControl_CustomCellValue
            End If
        End Sub

        Private Sub pivotGridControl_CustomCellValue(ByVal sender As Object, _
                                     ByVal e As PivotCellValueEventArgs)
            If e.Value IsNot Nothing AndAlso CDec(e.Value) < 2000 Then
                e.Value = 0
            End If
        End Sub

        Private Sub dashboardViewer1_DashboardItemControlUpdated(ByVal sender As Object, _
                                     ByVal e As DashboardItemControlEventArgs) _
                                 Handles dashboardViewer1.DashboardItemControlUpdated
            If e.DashboardItemName = "gridDashboardItem1" Then
                Dim gridView As GridView = TryCast(e.GridControl.MainView, GridView)
                gridView.Appearance.Row.Font = New Font("Arial", 10)
            End If
            If e.DashboardItemName = "chartDashboardItem1" Then
                Dim chartControl As ChartControl = e.ChartControl
                CType(chartControl.Diagram, XYDiagram).Panes(0).BackColor = Color.AliceBlue
            End If
        End Sub

        Private Sub dashboardViewer1_DashboardItemBeforeControlDisposed(ByVal sender As Object, _
                                     ByVal e As DashboardItemControlEventArgs) _
                                 Handles dashboardViewer1.DashboardItemBeforeControlDisposed
            If e.DashboardItemName = "pivotDashboardItem1" Then
                Dim pivotGridControl As PivotGridControl = e.PivotGridControl
                RemoveHandler pivotGridControl.CustomCellValue,
                    AddressOf pivotGridControl_CustomCellValue
            End If
        End Sub
    End Class
End Namespace
See Also