vb.net - Closing dropdown menustrip in webview2
问题描述
I have in a desktop application a webpage with a menustrip. I use webview2 as webbrowser control. When i click on the menustrip the menu dropsdown. The problem is that the dropdown doesn’t hide when i click on the webpage. In the standard vb net webbrowser this is not happening. So how can i hide the dropdown menu in webview2?
Maybe the answer lies in VB net. I am looking for a method to close the dropdown of the menustrip of my form i can call than this method from javascript on my webpage
解决方案
感谢 Jimi 和 Poul 我解决了这个问题。这对你来说很简单。解决方案: 1 我的网页是 openlayers 地图,其中有一个 eventlistner 供点击,
map.on('singleclick', function (event) {
var lonLat = ol.proj.toLonLat(event.coordinate);
var str = lonLat[0] + "," + lonLat[1];
(window.chrome.webview.hostObjects.sync.Bridge).Map_click(str);
});
vb net 2. 我使用 vb net 和 javascript WebView21.CoreWebView2.AddHostObjectToScript("Bridge", New Bridge()) 之间的桥梁,在我的 vb net 桌面应用程序和 Webppage 上的 javascript 之间架起一座桥梁。
3 我遍历菜单项并隐藏菜单项的下拉菜单
Private Sub clearmenustrip() For Each mnuitem As System.Windows.Forms.ToolStripMenuItem In Fmenu.MenuStrip1.Items
mnuitem.HideDropDown()
Next
End Sub
MenuStrip1 是表单中的菜单条
推荐阅读
- opengl - 在 Conda 环境中构建时找不到 OpenGL
- mysql - 如何找到 A 列的百分比
- python - 如何使用 azure devops python api。需要一些示例:获取用户故事信息、创建用户故事、更改状态
- sql - 如何从json字符串中提取一个值
- python - 如何在其他功能中使用我在第一个功能中找到的budget_amt?
- jquery - 如何优化移动分数的 jquery cdn 加载时间?
- datetime - 从现有时区获取值,MomentJS
- django - 带有 aws s3 的 Django 受限媒体文件仅对所有者可见
- javascript - 如何从对象中获取 FireStore 文档 ID?
- python - Python/Pygame:“pygame.error:显示表面退出”