DashboardPopupMenuShowingEventArgs Class
Provides data for the DashboardViewer.PopupMenuShowing, IDashboardControl.PopupMenuShowing, and the DashboardDesigner.PopupMenuShowing events.
Namespace: DevExpress.DashboardWin
Assembly: DevExpress.Dashboard.v24.1.Win.dll
NuGet Package: DevExpress.Win.Dashboard
Declaration
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 dashboardDesigner1_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");
}
}
}