Readonly Property SelectedItems() As System.Collections.IList
Collection of items in the list view that are selected (read-only).
The SelectedItems collection contains the subset of items returned from the GetItems event that the user has selected. Use it to respond to commands that act upon the selected items.
You can use the collection's Count to enable buttons only when an item is selected.
Private Sub editButton_Click(ByVal sender As Object, ByVal e As EventArgs)
' Open each selected person.
For Each person As Person In personListView.SelectedItems
EditPerson(person)
Next
End Sub
Private Sub deleteButton_Click(ByVal sender As Object, ByVal e As EventArgs)
' Delete each selected person.
For Each person As Person In personListView.SelectedItems
_document.DeletePerson(person)
Next
End Sub
Private Function ButtonEnabled() As Boolean
' The edit and delete buttons are enabled when a person is selected.
Return personListView.SelectedItems.Count > 0
End Function