PdfViewerBarItemLinkCollectionExtensions.GetPdfViewerBarItemLink(BarItemLinkCollection, PdfViewerCommandId) Method
Retrieves a menu item by its command’s identifying information.
Namespace: DevExpress.XtraPdfViewer.Extensions
Assembly: DevExpress.XtraPdfViewer.v19.2.dll
Declaration
public static BarItemLink GetPdfViewerBarItemLink(
this BarItemLinkCollection collection,
PdfViewerCommandId commandId
)
Parameters
Name | Type | Description |
---|---|---|
collection | BarItemLinkCollection | A target collection of DevExpress.XtraBars.BarItemLink items. |
commandId | PdfViewerCommandId | One of the PdfViewerCommandId enumeration values indicating the target item’s command ID. |
Returns
Type | Description |
---|---|
BarItemLink | A target BarItemLink object. |
Remarks
Use the GetPdfViewerBarItemLink method to access, remove, or disable any pop-up menu item. Handle the PdfViewer.PopupMenuShowing event to access the current pop-up menu. The PdfPopupMenuShowingEventArgs.ItemLinks property provides access to the collection of menu items.
This example shows how to hide the popup menu for the bookmark tree and remove specific items from the page content popup menu.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-remove-items-from-the-popup-menu-t602115
using System.Windows.Forms;
using DevExpress.XtraPdfViewer;
using DevExpress.XtraBars;
using DevExpress.XtraPdfViewer.Extensions;
namespace CustomPopupMenu
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
pdfViewer1.LoadDocument("..\\..\\Demo.pdf");
}
void pdfViewer1_PopupMenuShowing(object sender, PdfPopupMenuShowingEventArgs e)
{
// Hide the popup menu for the bookmark tree.
if (e.PopupMenuKind == PdfPopupMenuKind.BookmarkTree) {
e.ItemLinks.Clear();
}
// Remove Rotate Clockwise and Rotate Counterclockwise items from the Page Content popup menu.
if (e.PopupMenuKind == PdfPopupMenuKind.PageContent)
{
e.ItemLinks.Remove(e.ItemLinks.GetPdfViewerBarItemLink(PdfViewerCommandId.RotatePageClockwise));
e.ItemLinks.Remove(e.ItemLinks.GetPdfViewerBarItemLink(PdfViewerCommandId.RotatePageCounterclockwise));
}
}
}
}