Determine clicked column in ListView

后端 未结 4 1905
没有蜡笔的小新
没有蜡笔的小新 2020-12-14 12:08

I need to get the column clicked in a ListView in C#

I have some sample code from How to determine the clicked column index in a Listview but I\'m not sure how I sho

4条回答
  •  春和景丽
    2020-12-14 12:50

    This is VB.NET code, but the objects should be the same.

    Private LVUsersLastHit As Point
        Private Sub lvUsers_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lvUsers.MouseUp
            Me.LVUsersLastHit = e.Location
        End Sub
        Private Sub LvUsers_Doubleclick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lvUsers.DoubleClick
            Dim HTI As ListViewHitTestInfo = Me.lvUsers.HitTest(Me.LVUsersLastHit)
            If HTI.Item Is Nothing OrElse HTI.SubItem Is Nothing Then Exit Sub 'nothing was dblclicked
            MsgBox("doubleClicked the " & HTI.Item.ToString & " Item  on the " & HTI.SubItem.ToString & " sub Item")
        End Sub
    

提交回复
热议问题