PdfViewer.ContextMenuShowing Event

Occurs when the control's context menu is being displayed.

public event ContextMenuShowingEventHandler PdfViewer.ContextMenuShowing;
Public Event PdfViewer.ContextMenuShowing As ContextMenuShowingEventHandler

Event Handler

ContextMenuShowingEventHandler

Licensing Info

This event is a DynamicPDF Viewer feature. One of the following is required for non-evaluation usage:

Examples

This example demonstrates, how to hide/show the context menu , override the context menu of the control with a new one and setting the type context using ContextMenuShowingEventArgs class.

Imports System
Imports System.Windows.Forms
Imports ceTe.DynamicPDF.Viewer

Public Class Form1
    Inherits System.Windows.Forms.Form

    Private MyPdfViewer As PdfViewer

    Sub New()
        InitializeComponent()
    End Sub

    Shared Sub Main()
        Application.Run(New Form1())
    End Sub	
		    
    Private Sub InitializeComponent()
        Me.MyPdfViewer = New PdfViewer()
        Me.Controls.Add(MyPdfViewer)
        AddHandler MyPdfViewer.ContextMenuShowing, AddressOf MyPdfViewer_ContextMenuShowing
    End Sub

    Private Sub MyPdfViewer_ContextMenuShowing(ByVal sender As Object, ByVal e As ContextMenuShowingEventArgs)
        ' Suppress the control's existing context menu with a new context menu.
        e.AssignedContextMenu = New ContextMenuStrip()

        ' Create new ToolStripMenuItem and add it to AssignedContextMenu.
        Dim MyToolStripMenuitem1 As New ToolStripMenuItem()
        MyToolStripMenuitem1.Text = "Rotate"
        e.AssignedContextMenu.Items.Add(MyToolStripMenuitem1)

        ' Create new ToolStripMenuItem and add it to AssignedContextMenu.
        Dim MyToolStripMenuitem2 As New ToolStripMenuItem()
        MyToolStripMenuitem2.Text = "View"
        e.AssignedContextMenu.Items.Add(MyToolStripMenuitem2)

        ' Set the value to hide/show the context menu.
        e.Cancel = True
     End Sub

End Class
using System;
using System.Windows.Forms;
using ceTe.DynamicPDF.Viewer;

namespace DynamicPDFViewerDemo
{
    public class Form1 : Form
    {
        private PdfViewer dpdfViewer;

        public Form1()
        {
             InitializeComponent();
        }

        [STAThread]
        static void Main()
        {
            Application.Run(new Form1());
        }																															

        private void InitializeComponent()
        {
            this.dpdfViewer = new PdfViewer();
            this.Controls.Add(dpdfViewer);
            ContextMenuShowing += new ceTe.DynamicPDF.Viewer.ContextMenuShowingEventHandler(this.pdfViewer_ContextMenuShowing);
        }

        private void pdfViewer_ContextMenuShowing(object sender, ceTe.DynamicPDF.Viewer.ContextMenuShowingEventArgs e)
        {
            // Suppress the control's existing context menu with a new context menu.
            e.AssignedContextMenu = new ContextMenuStrip();

            // Create new ToolStripMenuItem and add it to AssignedContextMenu.
            ToolStripMenuItem toolStripMenuitem1 = new ToolStripMenuItem();
            toolStripMenuitem1.Text = "Rotate";
            e.AssignedContextMenu.Items.Add(toolStripMenuitem1);

            // Create new ToolStripMenuItem and add it to AssignedContextMenu.
            ToolStripMenuItem toolStripMenuitem2 = new ToolStripMenuItem();
            toolStripMenuitem2.Text = "View";
            e.AssignedContextMenu.Items.Add(toolStripMenuitem2);

            // Set the value to hide/show the context menu.
            e.Cancel = true;
        }
    }
}         

Remarks

If context menu displaying is disabled using this event, then both left and right mouse clicks will fire PdfViewerMouseClick event.

See Also

ceTe.DynamicPDF.Viewer

In this topic