dashboard-devexpress-dot-dashboardwin-dot-dashboardviewer-f4253264.md
Allows you to access underlying WinForms controls.
Namespace : DevExpress.DashboardWin
Assembly : DevExpress.Dashboard.v25.2.Win.dll
NuGet Package : DevExpress.Win.Dashboard
public event DashboardItemControlCreatedEventHandler DashboardItemControlCreated
Public Event DashboardItemControlCreated As DashboardItemControlCreatedEventHandler
The DashboardItemControlCreated event's data class is DashboardItemControlEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| CardControl | Gets an underlying Card control. |
| ChartContext | Gets the chart context. |
| ChartControl | Gets an underlying chart control. |
| DashboardItemName | Gets the component name of the dashboard item for which the event was raised. |
| DateFilterControl | Gets an underlying date filter control. |
| GaugeContext | Gets the gauge context. |
| GaugeControl | Gets an underlying gauge control. |
| GridContext | Gets the grid context. |
| 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. |
The WinForms Viewer uses DevExpress WinForms controls to visualize data within dashboard items. The DashboardViewer.DashboardItemControlUpdated event allows you to access these controls and customize their settings if necessary.
The DashboardItemControlEventArgs.DashboardItemName property returns the component name of the dashboard item to be customized. Use the following properties to access the corresponding underlying controls.
|
Dashboard Item
|
Control
|
Property
| | --- | --- | --- | |
|
|
DashboardItemControlEventArgs.GridControl
| |
|
|
DashboardItemControlEventArgs.ChartControl
| |
|
|
DashboardItemControlEventArgs.GaugeControl
| |
|
|
DashboardItemControlEventArgs.CardControl
| |
|
|
DashboardItemControlEventArgs.PivotGridControl
| |
|
|
DashboardItemControlEventArgs.MapControl
| |
|
|
DashboardItemControlEventArgs.TreeMapControl
| |
|
|
DashboardItemControlEventArgs.RichEditControl
| |
|
|
DashboardItemControlEventArgs.PictureEdit
| |
|
|
DashboardItemControlEventArgs.DateFilterControl
|
You can change the control setting or handle its events. To subscribe/unsubscribe from control events, use the DashboardItemControlCreated /DashboardViewer.DashboardItemBeforeControlDisposed events, respectively.
To learn more, see Access to Underlying Controls.
Note
The dashboard item is re-created when you maximize / restore the item. All events connected with a dashboard item life cycle (such as DashboardItemControlCreated, DashboardItemControlUpdated, etc.) are fired again.
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:
DashboardViewer.DashboardItemControlCreated and DashboardViewer.DashboardItemBeforeControlDisposed event handlers respectively.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 DirectCast(e.Value, Decimal) < 2000 Then
e.Value = "Too low to show"
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("Segoe Script", 10)
End If
If e.DashboardItemName = "chartDashboardItem1" Then
Dim chartControl As ChartControl = e.ChartControl
CType(chartControl.Diagram, XYDiagram).Panes(0).BackColor = Color.Orange
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
using System.Drawing;
using DevExpress.XtraEditors;
using DevExpress.DashboardWin;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraCharts;
using DevExpress.XtraPivotGrid;
namespace Dashboard_ControlAccess {
public partial class Form1 : XtraForm {
public Form1() {
InitializeComponent();
dashboardViewer1.LoadDashboard(@"..\..\Data\Dashboard.xml");
}
private void dashboardViewer1_DashboardItemControlCreated(object sender,
DashboardItemControlEventArgs e) {
if (e.DashboardItemName == "pivotDashboardItem1") {
PivotGridControl pivotGridControl = e.PivotGridControl;
pivotGridControl.CustomCellValue += pivotGridControl_CustomCellValue;
}
}
void pivotGridControl_CustomCellValue(object sender, PivotCellValueEventArgs e) {
if (e.Value != null && (decimal)e.Value < 2000)
e.Value = "Too low to show";
}
private void dashboardViewer1_DashboardItemControlUpdated(object sender,
DashboardItemControlEventArgs e) {
if (e.DashboardItemName == "gridDashboardItem1") {
GridView gridView = e.GridControl.MainView as GridView;
gridView.Appearance.Row.Font = new Font("Segoe Script", 10);
}
if (e.DashboardItemName == "chartDashboardItem1") {
ChartControl chartControl = e.ChartControl;
((XYDiagram)chartControl.Diagram).Panes[0].BackColor = Color.Orange;
}
}
private void dashboardViewer1_DashboardItemBeforeControlDisposed(object sender,
DashboardItemControlEventArgs e) {
if (e.DashboardItemName == "pivotDashboardItem1") {
PivotGridControl pivotGridControl = e.PivotGridControl;
pivotGridControl.CustomCellValue -= pivotGridControl_CustomCellValue;
}
}
}
}
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DashboardItemControlCreated event.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-dashboard-window-calculation-example/CS/WindowCalculationExample/Form1.cs#L17
dashboardViewer1.ConfigureDataConnection += DashboardViewer1_ConfigureDataConnection;
dashboardViewer1.DashboardItemControlCreated += DashboardViewer1_DashboardItemControlCreated;
dashboardViewer1.DashboardItemControlUpdated += DashboardViewer1_DashboardItemControlUpdated;
winforms-dashboard-window-calculation-example/VB/WindowCalculationExample/Form1.vb#L19
AddHandler dashboardViewer1.ConfigureDataConnection, AddressOf DashboardViewer1_ConfigureDataConnection
AddHandler dashboardViewer1.DashboardItemControlCreated, AddressOf DashboardViewer1_DashboardItemControlCreated
AddHandler dashboardViewer1.DashboardItemControlUpdated, AddressOf DashboardViewer1_DashboardItemControlUpdated
See Also