Reputation: 109
i need help to desactivate a button when there are any item select in my listview. here is my code :
Private Sub ListView_ItemSelectionChanged(____) Handles ListView.ItemSelectionChanged
If ListView.SelectedItems.Count > 0 Then
btnDelete.Enabled = False
End If
End Sub
i need to know which event shoul my procedure handle to make my program work correctly.
Upvotes: 1
Views: 84
Reputation: 54487
Surely you want Enabled
to be True
when items are selected, not False
. The other problem I see with your code is that it's not disabling the Button
again if no item is selected. Do this instead:
btnDelete.Enabled = (ListView.SelectedItems.Count > 0)
I'd also try a descriptive name for your ListView
.
Upvotes: 1