Back to Devexpress

DashboardToolbarMenuItem Class

dashboard-devexpress-dot-dashboardwin-7f569793.md

latest5.6 KB
Original Source

DashboardToolbarMenuItem Class

Drop-down menu element, contained in the dashboard title or dashboard item caption.

Namespace : DevExpress.DashboardWin

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

NuGet Package : DevExpress.Win.Dashboard

Declaration

csharp
public class DashboardToolbarMenuItem :
    IDashboardToolbarItem
vb
Public Class DashboardToolbarMenuItem
    Implements IDashboardToolbarItem

Remarks

Elements of this type are drop-down menu command buttons located in the dashboard title or dashboard item caption. They are contained in the DashboardToolbarItem.MenuItems collection of a command button. Command buttons are contained in the e.Items collection accessible in the following event handlers:

ComponentEvent
DashboardViewerCustomizeDashboardTitle, CustomizeDashboardItemCaption
DashboardDesignerCustomizeDashboardTitle, CustomizeDashboardItemCaption

Example

To add a drop-down menu item to the command button in the DashboardViewer’s dashboard title, handle the CustomizeDashboardTitle event, create a new .DashboardToolbarMenuItem instance, specify its characteristics and add it to the DashboardToolbarItem.MenuItems collection:

csharp
using DevExpress.DashboardWin;
// ...
dashboardViewer.CustomizeDashboardTitle += DashboardViewer_CustomizeDashboardTitle;
// ...
private void DashboardViewer_CustomizeDashboardTitle(object sender, CustomizeDashboardTitleEventArgs e)
{
    DashboardViewer viewer = (DashboardViewer)sender;

    // Add drop-down menu to show/hide dashboard item captions.
    DashboardToolbarItem toolbarItemRoot = new DashboardToolbarItem();
    toolbarItemRoot.Caption = "Show Dashboard Item Captions";
    toolbarItemRoot.SvgImage = svgImageCollection1["title"];
    foreach (var item in viewer.Dashboard.Items)
    {
        DashboardToolbarMenuItem menuItem = new DashboardToolbarMenuItem(item.ShowCaption, item.Name,
            new Action<DashboardToolbarItemClickEventArgs>((args) =>
            {
                item.ShowCaption = !item.ShowCaption;
            }));
        menuItem.ImageOptions.SvgImage = svgImageCollection1["title"];
        toolbarItemRoot.MenuItems.Add(menuItem);
    }
    e.Items.Insert(0, toolbarItemRoot);
}
vb
Imports DevExpress.DashboardWin
' ...
AddHandler dashboardViewer.CustomizeDashboardTitle, AddressOf DashboardViewer_CustomizeDashboardTitle
' ...
Private Sub DashboardViewer_CustomizeDashboardTitle(ByVal sender As Object, ByVal e As CustomizeDashboardTitleEventArgs)
    Dim viewer As DashboardViewer = DirectCast(sender, DashboardViewer)

    ' Add drop-down menu to show/hide dashboard item captions.
    Dim toolbarItemRoot As New DashboardToolbarItem()
    toolbarItemRoot.Caption = "Show Dashboard Item Captions"
    toolbarItemRoot.SvgImage = svgImageCollection1("title")
    For Each item In viewer.Dashboard.Items
        Dim menuItem As DashboardToolbarMenuItem = New DashboardToolbarMenuItem(item.ShowCaption, item.Name, New Action(Of DashboardToolbarItemClickEventArgs)(Sub(args)
            item.ShowCaption = Not item.ShowCaption
        End Sub))
        menuItem.ImageOptions.SvgImage = svgImageCollection1("title")
        toolbarItemRoot.MenuItems.Add(menuItem)
    Next item
    e.Items.Insert(0, toolbarItemRoot)

End Sub

View Example: WinForms Dashboard - How to customize the dashboard title and dashboard item captions

Implements

IDashboardToolbarItem

Inheritance

Object DashboardToolbarMenuItem

See Also

DashboardToolbarMenuItem Members

Dashboard Title in the WinForms Designer

Dashboard Item Caption in the WinForms Designer

Title and Item Captions

DevExpress.DashboardWin Namespace