Back to Devexpress

PdfViewerBarItemLinkCollectionExtensions.GetPdfViewerBarItemLink(BarItemLinkCollection, PdfViewerCommandId) Method

windowsforms-devexpress-dot-xtrapdfviewer-dot-extensions-dot-pdfviewerbaritemlinkcollectionextensions-dot-getpdfviewerbaritemlink-x28-baritemlinkcollection-pdfviewercommandid-x29.md

latest3.8 KB
Original Source

PdfViewerBarItemLinkCollectionExtensions.GetPdfViewerBarItemLink(BarItemLinkCollection, PdfViewerCommandId) Method

Retrieves a menu item by its command ID.

Namespace : DevExpress.XtraPdfViewer.Extensions

Assembly : DevExpress.XtraPdfViewer.v25.2.dll

NuGet Package : DevExpress.Win.PdfViewer

Declaration

csharp
public static BarItemLink GetPdfViewerBarItemLink(
    this BarItemLinkCollection collection,
    PdfViewerCommandId commandId
)
vb
<ExtensionAttribute>
Public Shared Function GetPdfViewerBarItemLink(
    collection As BarItemLinkCollection,
    commandId As PdfViewerCommandId
) As BarItemLink

Parameters

NameTypeDescription
collectionBarItemLinkCollection

A collection of BarItemLink items.

| | commandId | PdfViewerCommandId |

An enumeration value that indicates the item’s command ID.

|

Returns

TypeDescription
BarItemLink

A target menu item.

|

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 ItemLinks property obtains the collection of menu items.

Example

The code sample below shows how to change a caption of a built-in menu item:

csharp
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";
    }
}
vb
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

PdfViewerBarItemLinkCollectionExtensions Members

DevExpress.XtraPdfViewer.Extensions Namespace