Web 浏览器控件 - 防止右键单击
在我的应用程序中,我有一个包含浏览器控件的表单,我在其中显示 SSRS 报告。我想阻止用户右键单击浏览器控件并显示弹出菜单。理想情况下,我希望右键单击不执行任何操作。有什么方法可以实现这个目标吗?
In my application, I have a form that contains a browser control in which I display an SSRS report. I would like to prevent the user from right-clicking in the browser control and being shown the popup menu. Ideally I'd like the right-click to do nothing. Is there a way I can accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以将 IsWebBrowserContextMenuEnabled 设置为 false。您可能还想将AllowWebBrowserDrop 设置为 false,这样他们就无法将网址拖到应用程序中并加载它。
You can set the IsWebBrowserContextMenuEnabled equal to false. You will probably also want to set AllowWebBrowserDrop equal to false too so they cant drag a url into the app and have it load.
对于任何情况,winform 或 wpf:
for any case, winform or wpf:
对于WPF ===>
wbBrowser.ContextMenu.IsEnabled = false;
For WPF ===>
wbBrowser.ContextMenu.IsEnabled = false;
将
IsWebBrowserContextMenuEnabled
属性设置为false
。Set the
IsWebBrowserContextMenuEnabled
property tofalse
.我的项目(WPF - MVVM)有一个解决方案:
重要添加参考:Microsoft.mshtml
实现事件:webBrowser.LoadCompleted += webBrowser_LoadCompleted;
希望有帮助。
I have a solution work on my project (WPF - MVVM):
Important add reference: Microsoft.mshtml
Implement event: webBrowser.LoadCompleted += webBrowser_LoadCompleted;
Hope helpful.