Reputation: 23
I used a listview (to simplify i added one item) and when i click it a messagebox is shown. when i close the messagebox and click again the item the messagebox appears twice i must to close it twice
Private Sub ListView1_ItemSelectionChanged(sender As Object, e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles ListView1.ItemSelectionChanged
Select Case e.ItemIndex
Case 0
MessageBox.Show("AAAA")
End Select
End Sub
Thanks
Upvotes: 0
Views: 31
Reputation: 15774
The SelectionChanged event fires when an item is selected or deselected. If you only care about when an item is selected, try checking if the item is selected first.
Private Sub ListView1_ItemSelectionChanged(sender As Object, e As ListViewItemSelectionChangedEventArgs) Handles ListView1.ItemSelectionChanged
If Not e.IsSelected Then Exit Sub
Select Case e.ItemIndex
Case 0
MessageBox.Show("AAAA")
End Select
End Sub
Upvotes: 0