How do i get the SelectedItem or SelectedIndex of ListView in vb.net

前端 未结 7 1901
闹比i
闹比i 2020-12-10 13:04

As you know by question that what I want. I was using listbox. In ListBox we can get selected item by a simple line of code: listbox1.SelectedItem.

7条回答
  •  囚心锁ツ
    2020-12-10 13:47

    If you want to select the same item in a listbox using a listview, you can use:

    Private Sub ListView1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListView1.SelectedIndexChanged
        For aa As Integer = 0 To ListView1.SelectedItems.Count - 1
            ListBox1.SelectedIndex = ListView1.SelectedIndices(aa)
        Next
    End Sub
    

提交回复
热议问题