上下文菜单项
我为 UltrawinGrid 制作了上下文菜单,当我单击鼠标右键时,上下文菜单将打开。
这是我用于菜单的代码:
Private Sub ShowContextMenu(ByVal mousePoint As Point)
Dim cMenu As ContextMenu = New ContextMenu
cMenu.MenuItems.Add("Delete")
cMenu.MenuItems.Add("Copy")
cMenu.MenuItems.Add("Paste")
cMenu.Show(UltraGrid1, mousePoint)
End Sub
现在我想当我单击上下文菜单项(例如删除)时调用已执行某些操作的函数,我该怎么做?如何在菜单项和功能之间建立联系?
I made context menu for UltrawinGrid, when i click right mouse button then the context menu open.
This is the code that I use for my menu:
Private Sub ShowContextMenu(ByVal mousePoint As Point)
Dim cMenu As ContextMenu = New ContextMenu
cMenu.MenuItems.Add("Delete")
cMenu.MenuItems.Add("Copy")
cMenu.MenuItems.Add("Paste")
cMenu.Show(UltraGrid1, mousePoint)
End Sub
Now I want when I click on context menu item, for example delete, to call function that gone do something, how i can do this? How I can make connection between menu items and functions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须添加一个事件处理程序:
以及方法:
You have to add an event handler:
And the method:
不确定 UltrawinGrid,但通常您应该能够将上下文菜单关联到控件。上下文菜单控件在工具箱中以 ContextMenuStrip 形式提供。将其放入设计器中,指定菜单项并通过设计器连接事件。这是更简单的方法。
无论出于何种原因,如果您无法执行上述操作,您将必须在代码中手动为每个菜单项连接您自己的事件处理程序,如下所示:
Not sure about the UltrawinGrid, but typically you should be able to associate a Context Menu to a control. Context Menu control is available in your toolbox as ContextMenuStrip. Drop that in your designer, specify the menu item and wire up the event through the designer. That is much easier way to do it.
For whatever reason if you cant do the above, you will have to manually for each menu item wireup your own event handler in the code like this: