How to remove items from Right Click menu

How to remove items from Right Click menu

Forum member · Apr 6, 2023
Hi , I am evaluating DynamicPDF Viewer for .NET, would like to know how to remove items from right click menu. Thanks,

Re: How to remove items from Right Click menu

Support · Apr 7, 2023
Hi, You can achieve your requirement by suppressing the default contextmenu and setting your own custom context menu. You can suppress default context menu in ContextMenuShowing event and add a custom one. You will need create a new context menu by adding items to it and set respective actions in item click event. Here is a code sample Code sample to trigger an event. pdfViewer1.ContextMenuShowing+=new ContextMenuShowingEventHandler(pdfViewer1_ContextMenuShowing); Event handler code sample to hide default and add new context menu. void pdfViewer1_ContextMenuShowing(object sender, ContextMenuShowingEventArgs e) { e.Cancel = true; ContextMenuStrip newMenu = new ContextMenuStrip(); e.AssignedContextMenu = newMenu; ToolStripItem item3 = newMenu.Items.Add("Print"); item3.Click += new EventHandler(item3_Click); } Event handler for item click event. void item3_Click(object sender, EventArgs e) { MessageBox.Show("Add printing action in this event"); //pdfViewer1.Print(); } Thanks, ceTe Software Support Team