简体   繁体   English

显示 ListView 中项目的上下文菜单

[英]Showing a Context Menu for an item in a ListView

I know how to make a contextMenu that pops up when I right click on a listView, what I want is for it to pop up when I right click on an item .我知道如何制作一个在我右键单击 listView 时弹出的 contextMenu,我想要的是当我右键单击一个item时它会弹出。 I am trying to make a chat server and client, and now... Now I want to view client info when I right click on a connected client's item.我正在尝试制作聊天服务器和客户端,现在...现在我想在我右键单击已连接客户端的项目时查看客户端信息。

How can I do this?我怎样才能做到这一点?

I know how to make a contextMenu that pops up when I right click on a listView, what I want is for it to pop up when I right click on an item .我知道如何制作一个contextMenu,当我右键单击一个listView时会弹出,我想要的是当我右键单击一个item时会弹出它。 I am trying to make a chat server and client, and now... Now I want to view client info when I right click on a connected client's item.我正在尝试制作聊天服务器和客户端,现在...现在,我想在右键单击连接的客户端项目时查看客户端信息。

How can I do this?我怎样才能做到这一点?

I know how to make a contextMenu that pops up when I right click on a listView, what I want is for it to pop up when I right click on an item .我知道如何制作一个contextMenu,当我右键单击一个listView时会弹出,我想要的是当我右键单击一个item时会弹出它。 I am trying to make a chat server and client, and now... Now I want to view client info when I right click on a connected client's item.我正在尝试制作聊天服务器和客户端,现在...现在,我想在右键单击连接的客户端项目时查看客户端信息。

How can I do this?我怎样才能做到这一点?

I know how to make a contextMenu that pops up when I right click on a listView, what I want is for it to pop up when I right click on an item .我知道如何制作一个contextMenu,当我右键单击一个listView时会弹出,我想要的是当我右键单击一个item时会弹出它。 I am trying to make a chat server and client, and now... Now I want to view client info when I right click on a connected client's item.我正在尝试制作聊天服务器和客户端,现在...现在,我想在右键单击连接的客户端项目时查看客户端信息。

How can I do this?我怎样才能做到这一点?

I know how to make a contextMenu that pops up when I right click on a listView, what I want is for it to pop up when I right click on an item .我知道如何制作一个contextMenu,当我右键单击一个listView时会弹出,我想要的是当我右键单击一个item时会弹出它。 I am trying to make a chat server and client, and now... Now I want to view client info when I right click on a connected client's item.我正在尝试制作聊天服务器和客户端,现在...现在,我想在右键单击连接的客户端项目时查看客户端信息。

How can I do this?我怎样才能做到这一点?

I know how to make a contextMenu that pops up when I right click on a listView, what I want is for it to pop up when I right click on an item .我知道如何制作一个contextMenu,当我右键单击一个listView时会弹出,我想要的是当我右键单击一个item时会弹出它。 I am trying to make a chat server and client, and now... Now I want to view client info when I right click on a connected client's item.我正在尝试制作聊天服务器和客户端,现在...现在,我想在右键单击连接的客户端项目时查看客户端信息。

How can I do this?我怎样才能做到这一点?

I know how to make a contextMenu that pops up when I right click on a listView, what I want is for it to pop up when I right click on an item .我知道如何制作一个contextMenu,当我右键单击一个listView时会弹出,我想要的是当我右键单击一个item时会弹出它。 I am trying to make a chat server and client, and now... Now I want to view client info when I right click on a connected client's item.我正在尝试制作聊天服务器和客户端,现在...现在,我想在右键单击连接的客户端项目时查看客户端信息。

How can I do this?我怎样才能做到这一点?

I know how to make a contextMenu that pops up when I right click on a listView, what I want is for it to pop up when I right click on an item .我知道如何制作一个contextMenu,当我右键单击一个listView时会弹出,我想要的是当我右键单击一个item时会弹出它。 I am trying to make a chat server and client, and now... Now I want to view client info when I right click on a connected client's item.我正在尝试制作聊天服务器和客户端,现在...现在,我想在右键单击连接的客户端项目时查看客户端信息。

How can I do this?我怎样才能做到这一点?

Using DevExpress 20.2 Core... Winforms.使用 DevExpress 20.2 核心... Winforms。 This is similar to handling a menu item in a GridView.这类似于处理 GridView 中的菜单项。

Private WithEvents _menuViewLabelitem As MenuItem
    Private Sub lvShipTracking_MouseClick(sender As Object, e As MouseEventArgs) Handles lvShipTracking.MouseClick

    If e.Button = MouseButtons.Right Then

        If lvShipTracking.FocusedItem IsNot Nothing AndAlso lvShipTracking.FocusedItem.Bounds.Contains(e.Location) = True Then
            Dim m As ContextMenu = New ContextMenu()
            _menuViewLabelitem = New MenuItem("View Label")

            AddHandler Click, AddressOf Handle_ViewLabel

            m.MenuItems.Add(_menuViewLabelitem)
            m.Show(lvShipTracking, New Point(e.X, e.Y))
        End If
    End If

End Sub

Private Sub Handle_ViewLabel(sender As Object, e As EventArgs) Handles _menuViewLabelitem.Click
    MsgBox("it worked!")
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM