The requested page is not available for the requested platform. You are viewing the content for Default platform.
All docs
V19.1
19.2 (preview)
19.1
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Title and Item Captions

  • 3 min to read

The Dashboard Title and Dashboard Item Caption are areas located on the dashboard surface and may contain relevant up-to-date information regarding the displayed data and command buttons, which allow end-users to easily perform common activities. Title and captions are already packed with useful indicators and buttons, but you can also deliberately hide built-in items or add your own.

win-viewer-command-buttons-in-title-and-captions

This example demonstrates how to handle the CustomizeDashboardTitle and CustomizeDashboardItemCaption events to add command buttons with custom actions.

Note

The complete sample project How to Add a Command Button to the Dashboard Title and Item Caption is available in the DevExpress Examples repository.

using DevExpress.DashboardCommon;
using DevExpress.DashboardWin;

namespace CommandButtonForTitleAndCaption
{
    public partial class Form1 : DevExpress.XtraEditors.XtraForm
    {
        public Form1()
        {
            InitializeComponent();
            dashboardViewer1.ConfigureDataConnection += DashboardViewer1_ConfigureDataConnection;
            dashboardViewer1.CustomizeDashboardTitle += DashboardViewer1_CustomizeDashboardTitle;
            dashboardViewer1.CustomizeDashboardItemCaption += DashboardViewer1_CustomizeDashboardItemCaption;
            dashboardViewer1.LoadDashboard("DashboardTest.xml");
        }

        private void DashboardViewer1_CustomizeDashboardTitle(object sender, CustomizeDashboardTitleEventArgs e)
        {
            DashboardToolbarItem item = new DashboardToolbarItem(
                (args) =>
                {
                    System.Diagnostics.Process.Start("https://docs.devexpress.com/Dashboard/");
                })
            {
                SvgImage = svgImageCollection1["needassistance"],
                Caption = "Online Help",
                Tooltip = "Navigate to the online Dashboard help"
            };
            e.Items.Add(item);
        }
        private void DashboardViewer1_CustomizeDashboardItemCaption(object sender, CustomizeDashboardItemCaptionEventArgs e)
        {
            DashboardViewer viewer = sender as DashboardViewer;
            GridDashboardItem gridItem = viewer.Dashboard.Items[e.DashboardItemName] as GridDashboardItem;
            if (gridItem != null)
            {
                DashboardToolbarItem cmdButtonItem = new DashboardToolbarItem
                {
                    ClickAction = args => SwitchGridMeasureColumnDisplayMode(gridItem),
                    SvgImage = svgImageCollection1["bluedatabarsolid"],
                    Tooltip = "Switch between bars and numbers"
                };
                e.Items.Insert(0, cmdButtonItem);
            };

        }

        private void SwitchGridMeasureColumnDisplayMode(GridDashboardItem gridItem)
        {
            foreach (var column in gridItem.Columns)
            {
                GridMeasureColumn measureColumn = column as GridMeasureColumn;
                if (measureColumn != null)
                {
                    switch (measureColumn.DisplayMode)
                    {
                        case GridMeasureColumnDisplayMode.Bar:
                            measureColumn.DisplayMode = GridMeasureColumnDisplayMode.Value;
                            break;
                        case GridMeasureColumnDisplayMode.Value:
                            measureColumn.DisplayMode = GridMeasureColumnDisplayMode.Bar;
                            break;
                    }
                }
            }
        }
        private void DashboardViewer1_ConfigureDataConnection(object sender, DashboardConfigureDataConnectionEventArgs e)
        {
            if (e.ConnectionParameters is ExcelDataSourceConnectionParameters connParams)
                connParams.FileName = "SalesPerson.xlsx";
        }
    }
}
See Also