dashboard-devexpress-dot-dashboardwin-dot-dashboardviewer-7c413b9b.md
Allows you to customize the pop-up menu that users invoke in the DashboardViewer.
Namespace : DevExpress.DashboardWin
Assembly : DevExpress.Dashboard.v25.2.Win.dll
NuGet Package : DevExpress.Win.Dashboard
public event DashboardPopupMenuShowingEventHandler PopupMenuShowing
Public Event PopupMenuShowing As DashboardPopupMenuShowingEventHandler
The PopupMenuShowing event's data class is DashboardPopupMenuShowingEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Allow | Gets or sets whether end-users can invoke a popup menu. |
| ButtonType | Gets the type of the clicked command button. |
| DashboardArea | Gets the value that identifies a popup menu location within the dashboard. |
| DashboardItemArea | Gets the area of the dashboard item for which the event has been raised. |
| DashboardItemName | Gets the name of the dashboard item for which the event has been raised. Inherited from DashboardItemMouseEventArgs. |
| Data | Gets the dashboard item’s client data. Inherited from DashboardItemMouseHitTestEventArgs. |
| Menu | Gets or sets a popup menu. |
The event data class exposes the following methods:
| Method | Description |
|---|---|
| GetAxisPoint() | Returns the axis point corresponding to the visual element located under the test point. Inherited from DashboardItemMouseHitTestEventArgs. |
| GetAxisPoint(String) | Returns the axis point corresponding to the visual element located under the test point. Inherited from DashboardItemMouseHitTestEventArgs. |
| GetDeltas() | Gets a list of deltas corresponding to the visual element located under the test point. Inherited from DashboardItemMouseHitTestEventArgs. |
| GetMeasures() | Gets a list of measures corresponding to the visual element located under the test point. Inherited from DashboardItemMouseHitTestEventArgs. |
| GetSlice() | Returns the slice of client data by the axis point corresponding to the visual element located under the test point. Inherited from DashboardItemMouseHitTestEventArgs. |
| GetSlice(String) | Returns the slice of client data by the axis point corresponding to the visual element located under the test point. Inherited from DashboardItemMouseHitTestEventArgs. |
| GetUnderlyingData() | Returns underlying data corresponding to the visual element located under the test point. Inherited from DashboardItemMouseHitTestEventArgs. |
| GetUnderlyingData(IList<String>) | Returns underlying data corresponding to the visual element located under the test point. Inherited from DashboardItemMouseHitTestEventArgs. |
| GetUnderlyingData(String, IList<String>) | Returns underlying data corresponding to the visual element located under the test point. Inherited from DashboardItemMouseHitTestEventArgs. |
| GetUnderlyingData(String) | Returns underlying data corresponding to the visual element located under the test point. Inherited from DashboardItemMouseHitTestEventArgs. |
The PopupMenuShowing event occurs when a user invokes a pop-up menu in the UI. This event allows you to customize the pop-up menu that is invoked when a user right-clicks a dashboard item or clicks a command button in the dashboard title or the dashboard item caption.
Use the following properties in the PopupMenuShowing event handler to customize the pop-up menu:
The e.DashboardArea property identifies the pop-up menu’s location. The e.DashboardItemArea property gets the area of the target dashboard item.
The e.DashboardItemName property obtains the dashboard item name for which the event is raised. To identify the clicked command button, use the e.ButtonType property.
Use the e.Menu property to customize the pop-up menu. You can set the e.Allow property to false or assign null to the e.Menu property to prevent users from invoking the menu.
The following example shows how to customize the Pivot dashboard item’s pop-up menu:
The PopupMenuShowing event occurs each time a user invokes a pop-up menu and adds the “Custom Menu Item” link to the Pivot’s menu. Note that you need to remove the previously added “Custom Menu Item” link from BarItemLinkCollection each time the event fires. Otherwise, the pop-up menu creates “Custom Menu Item” copies.
using DevExpress.XtraBars;
using System.Data;
using System.Linq;
using System.Windows.Forms;
namespace DashboardSample {
public partial class Form1 : Form {
// Creates a new bar item.
BarButtonItem _newBarItem;
BarButtonItem NewBarItem {
get {
if (_newBarItem == null) {
_newBarItem = new BarButtonItem();
_newBarItem.Caption = "Custom Menu Item";
_newBarItem.ItemClick += NewItem_ItemClick;
}
return _newBarItem;
}
}
public Form1() {
InitializeComponent();
dashboardDesigner1.CreateRibbon();
dashboardDesigner1.LoadDashboard("DataFolder/nwind.xml");
}
private void dashboardViewer1_PopupMenuShowing(object sender, DevExpress.DashboardWin.DashboardPopupMenuShowingEventArgs e) {
BarItemLink existingItemLink = e.Menu.ItemLinks.Where(link => link.Item == _newBarItem).FirstOrDefault();
if (e.DashboardItemName == "pivotDashboardItem1") {
// Inserts the item link in the Pivot's pop-up menu.
if (existingItemLink != null)
e.Menu.ItemLinks.Remove(existingItemLink);
e.Menu.ItemLinks.Insert(0, NewBarItem);
}
else {
// Removes the added link for other dashboard items.
e.Menu.ItemLinks.Remove(existingItemLink);
}
}
// Shows a message when a user clicks the Custom Menu Item in the invoked pop-up menu.
private void NewItem_ItemClick(object sender, ItemClickEventArgs e) {
MessageBox.Show("Custom Menu Item Clicked");
}
}
}
Imports DevExpress.XtraBars
Imports System.Data
Imports System.Linq
Imports System.Windows.Forms
Namespace DesignerSample
Partial Public Class Form1
Inherits Form
' Creates a new bar item.
Private _newBarItem As BarButtonItem
Private ReadOnly Property NewBarItem() As BarButtonItem
Get
If _newBarItem Is Nothing Then
_newBarItem = New BarButtonItem()
_newBarItem.Caption = "Custom Menu Item"
AddHandler _newBarItem.ItemClick, AddressOf NewItem_ItemClick
End If
Return _newBarItem
End Get
End Property
Public Sub New()
InitializeComponent()
dashboardDesigner1.CreateRibbon()
dashboardDesigner1.LoadDashboard("DataFolder/nwind.xml")
End Sub
Private Sub dashboardDesigner1_PopupMenuShowing(ByVal sender As Object, ByVal e As DevExpress.DashboardWin.DashboardPopupMenuShowingEventArgs)
Dim existingItemLink As BarItemLink = e.Menu.ItemLinks.Where(Function(link) link.Item Is _newBarItem).FirstOrDefault()
If e.DashboardItemName = "pivotDashboardItem1" Then
' Inserts the item link in the Pivot's pop-up menu.
If existingItemLink IsNot Nothing Then
e.Menu.ItemLinks.Remove(existingItemLink)
End If
e.Menu.ItemLinks.Insert(0, NewBarItem)
Else
' Removes the added link for other dashboard items.
e.Menu.ItemLinks.Remove(existingItemLink)
End If
End Sub
' Shows a message when a user clicks the Custom Menu Item in the invoked pop-up menu.
Private Sub NewItem_ItemClick(ByVal sender As Object, ByVal e As ItemClickEventArgs)
MessageBox.Show("Custom Menu Item Clicked")
End Sub
End Class
End Namespace
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the PopupMenuShowing 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.
dashboardViewer.PopupMenuShowing += DashboardViewer_PopupMenuShowing;
dashboardViewer.MasterFilterSet += DashboardViewer_MasterFilterSet;
AddHandler dashboardViewer.PopupMenuShowing, AddressOf DashboardViewer_PopupMenuShowing
AddHandler dashboardViewer.MasterFilterSet, AddressOf DashboardViewer_MasterFilterSet
See Also
IDashboardControl.PopupMenuShowing
DashboardDesigner.PopupMenuShowing