Back to Devexpress

DashboardItemControlEventArgs.GridContext Property

dashboard-devexpress-dot-dashboardwin-dot-dashboarditemcontroleventargs-397c7cf6.md

latest5.6 KB
Original Source

DashboardItemControlEventArgs.GridContext Property

Gets the grid context.

Namespace : DevExpress.DashboardWin

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

NuGet Package : DevExpress.Win.Dashboard

Declaration

csharp
public GridContext GridContext { get; }
vb
Public ReadOnly Property GridContext As GridContext

Property Value

TypeDescription
GridContext

A context used to provide a connection between data item containers from the Columns section and underlying control’s columns.

|

Remarks

The grid context provides the connection between dashboard data item containers from the Columns section and the underlying control’s columns. The GetControlColumn method returns a data item container that corresponds to the specified control’s column. The GetDashboardItemColumn method, in turn, gets a control’s column that corresponds to the specified data item container from the Columns section.

For example, the Grid dashboard item has dimension, measure and delta columns (data item containers in the Columns section). In this case, the underlying Grid control also displays three columns: State, Sales (Sum) and Sales vs Target. The image below shows these elements that define Grid context:

When you pass the State data item container as the GetControlColumn method parameter, you get a GridColumn column in return:

On the contrary, if you pass one of the GridColumn object as the GetDashboardItemColumn method parameter, you get a column (a data item container from the Columns section) in the selected Grid dashboard item that corresponds this control’s column:

The following code snippet shows how to set a back color for a Grid’s measure column. The DashboardDesigner.DashboardItemControlUpdated event is used to update the Grid’s appearance.

csharp
using DevExpress.DashboardCommon;
using DevExpress.DashboardWin;
using System.Drawing;

// ...

private void DashboardDesigner1_DashboardItemControlUpdated(object sender, DashboardItemControlEventArgs e) {
    if(e.GridControl != null) {
        DashboardDesigner designer = (DashboardDesigner)sender;
        var gridDashboardItem = designer.Dashboard.Items[e.DashboardItemName] as GridDashboardItem;
        foreach(var dashGridColumn in gridDashboardItem.Columns) {
            if(dashGridColumn is GridMeasureColumn && dashGridColumn != null) {
                var column = e.GridContext.GetGridControlColumn(dashGridColumn);
                column.AppearanceCell.BackColor = Color.LightCyan;
            }
        }            
    }
}
vb
Imports DevExpress.DashboardCommon
Imports DevExpress.DashboardWin
Imports System.Drawing

' ...

Private Sub DashboardDesigner1_DashboardItemControlUpdated(ByVal sender As Object, ByVal e As DashboardItemControlEventArgs)
    If e.GridControl IsNot Nothing Then
        Dim designer As DashboardDesigner = CType(sender, DashboardDesigner)
        Dim gridDashboardItem = TryCast(designer.Dashboard.Items(e.DashboardItemName), GridDashboardItem)
        For Each dashGridColumn In gridDashboardItem.Columns
            If TypeOf dashGridColumn Is GridMeasureColumn AndAlso dashGridColumn IsNot Nothing Then
                Dim column = e.GridContext.GetGridControlColumn(dashGridColumn)
                column.AppearanceCell.BackColor = Color.LightCyan
            End If
        Next dashGridColumn
    End If
End Sub

See Also

DashboardItemControlEventArgs Class

DashboardItemControlEventArgs Members

DevExpress.DashboardWin Namespace