DashboardViewer.PopupMenuShowing Event
Allows you to customize the pop-up menu that users invoke in the DashboardViewer.
Namespace: DevExpress.DashboardWin
Assembly: DevExpress.Dashboard.v24.1.Win.dll
NuGet Package: DevExpress.Win.Dashboard
Declaration
Event Data
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. |
Remarks
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.
Example
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");
}
}
}
Related GitHub Examples
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.