Skip to main content
A newer version of this page is available. .

How to: Access the Dashboard Control

  • 3 minutes to read

This topic describes how to access the DashboardViewer control in a WinForms application and the ASPxDashboard control in an ASP.NET application.

Note

Refer to the How to: Access the WinForms Dashboard Designer topic for details on how to access the DashboardDesigner control.

Important

Before you proceed, ensure that:

  • your WinForms module project references the DevExpress.Dashboard.v19.1.Win.dll and DevExpress.ExpressApp.Dashboards.Win.v19.1.dll assemblies;
  • your ASP.NET module project references the DevExpress.Dashboard.v19.1.Web.dll and DevExpress.ExpressApp.Dashboards.Web.v19.1.dll assemblies.

Follow these steps in WinForms and ASP.NET module projects to access the dashboard control:

using System;
using DevExpress.DashboardWin;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Dashboards.Win;
using DevExpress.Persistent.Base;
// ...
public class WinDashboardController : ObjectViewController<DetailView, IDashboardData> {
    private WinDashboardViewerViewItem dashboardViewerViewItem;
    protected override void OnActivated() {
        base.OnActivated();
        dashboardViewerViewItem = View.FindItem("DashboardViewer") as WinDashboardViewerViewItem;
        if(dashboardViewerViewItem != null) {
            if(dashboardViewerViewItem.Viewer != null) {
                CustomizeDashboardViewer(dashboardViewerViewItem.Viewer);
            }
            else {
                dashboardViewerViewItem.ControlCreated += DashboardViewerViewItem_ControlCreated;
            }
        }
    }
    private void DashboardViewerViewItem_ControlCreated(object sender, EventArgs e) {
        CustomizeDashboardViewer(((WinDashboardViewerViewItem)sender).Viewer);
    }
    private void CustomizeDashboardViewer(DashboardViewer dashboardViewer) {
        dashboardViewer.AllowPrintDashboardItems = true;
    }
    protected override void OnDeactivated() {
        if(dashboardViewerViewItem != null) {
            dashboardViewerViewItem.ControlCreated -= DashboardViewerViewItem_ControlCreated;
            dashboardViewerViewItem = null;
        }
        base.OnDeactivated();
    }
}