WebBrowser控件 - 防止右键单击

Ran*_*der 14 c# browser webbrowser-control reporting-services

在我的应用程序中,我有一个包含浏览器控件的表单,我在其中显示SSRS报告.我想阻止用户右键单击浏览器控件并显示弹出菜单.理想情况下,我希望右键单击不执行任何操作.有没有办法可以做到这一点?

Chr*_*ken 23

您可以将IsWebBrowserContextMenuEnabled设置为false.您可能还希望将AllowWebBrowserDrop设置为false,这样他们就无法将url拖到应用程序中并加载它.

        webBrowser1.IsWebBrowserContextMenuEnabled = false;
        webBrowser1.AllowWebBrowserDrop = false;
Run Code Online (Sandbox Code Playgroud)

  • 适用于Winforms WebBrowser,而不适用于WPF版本. (3认同)