上下文菜单项

发布于 2024-08-22 23:14:06 字数 438 浏览 11 评论 0原文

我为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

能否归途做我良人 2024-08-29 23:14:06

您必须添加一个事件处理程序:

cMenu.MenuItems.Add("Delete", mnuDelete_OnClick)

以及方法:

Private Sub mnuDelete_OnClick(sender As System.Object, e As System.EventArgs)
End Sub

You have to add an event handler:

cMenu.MenuItems.Add("Delete", mnuDelete_OnClick)

And the method:

Private Sub mnuDelete_OnClick(sender As System.Object, e As System.EventArgs)
End Sub
美人如玉 2024-08-29 23:14:06

不确定 UltrawinGrid,但通常您应该能够将上下文菜单关联到控件。上下文菜单控件在工具箱中以 ContextMenuStrip 形式提供。将其放入设计器中,指定菜单项并通过设计器连接事件。这是更简单的方法。

无论出于何种原因,如果您无法执行上述操作,您将必须在代码中手动为每个菜单项连接您自己的事件处理程序,如下所示:

    cMenuSubItem1.Click +=new EventHandler(tesToolStripMenuItem_Click);

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:

    cMenuSubItem1.Click +=new EventHandler(tesToolStripMenuItem_Click);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文