windowsforms-devexpress-dot-xtrapdfviewer-dot-extensions-dot-pdfviewerbaritemlinkcollectionextensions-dot-getpdfviewerbaritemlink-x28-baritemlinkcollection-pdfviewercommandid-x29.md
Retrieves a menu item by its command ID.
Namespace : DevExpress.XtraPdfViewer.Extensions
Assembly : DevExpress.XtraPdfViewer.v25.2.dll
NuGet Package : DevExpress.Win.PdfViewer
public static BarItemLink GetPdfViewerBarItemLink(
this BarItemLinkCollection collection,
PdfViewerCommandId commandId
)
<ExtensionAttribute>
Public Shared Function GetPdfViewerBarItemLink(
collection As BarItemLinkCollection,
commandId As PdfViewerCommandId
) As BarItemLink
| Name | Type | Description |
|---|---|---|
| collection | BarItemLinkCollection |
A collection of BarItemLink items.
| | commandId | PdfViewerCommandId |
An enumeration value that indicates the item’s command ID.
|
| Type | Description |
|---|---|
| BarItemLink |
A target menu item.
|
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 ItemLinks property obtains the collection of menu items.
The code sample below shows how to change a caption of a built-in menu item:
using DevExpress.XtraPdfViewer;
using DevExpress.XtraPdfViewer.Commands;
using DevExpress.XtraPdfViewer.Extensions;
//...
void pdfViewer1_PopupMenuShowing(object sender, PdfPopupMenuShowingEventArgs e)
{
// Retrieve a Hand Tool item
// in the Page Content menu.
if (e.PopupMenuKind == PdfPopupMenuKind.PageContent)
{
var handToolItem =
e.ItemLinks.GetPdfViewerBarItemLink(PdfViewerCommandId.HandTool);
// Change the item caption.
handToolItem.Caption = "Custom Caption";
}
}
Imports DevExpress.XtraPdfViewer
Imports DevExpress.XtraPdfViewer.Commands
Imports DevExpress.XtraPdfViewer.Extensions
'...
Private Sub pdfViewer1_PopupMenuShowing(ByVal sender As Object, ByVal e As PdfPopupMenuShowingEventArgs)
If e.PopupMenuKind = PdfPopupMenuKind.PageContent Then
Dim handToolItem = e.ItemLinks.GetPdfViewerBarItemLink(PdfViewerCommandId.HandTool)
handToolItem.Caption = "Custom Caption"
End If
End Sub
See Also
PdfViewerBarItemLinkCollectionExtensions Class