[RESOLVED] clear selected highlighted for the items in the listbox
I have 4 listbox, when I select the items in the listbox1, how I can clear selected highlighted in other listbox ?I used code below, but when I select the items in listbox, it clear all the selected highlighted items and I have to reselect the items again in the listbox1
Code:
Private Sub List1_Click()
List2.ListIndex = -1
List3.ListIndex = -1
List4.ListIndex = -1
End Sub
Private Sub List2_Click()
List1.ListIndex = -1
List3.ListIndex = -1
List4.ListIndex = -1
End Sub
Private Sub List3_Click()
List1.ListIndex = -1
List2.ListIndex = -1
List4.ListIndex = -1
End Sub
Private Sub List4_Click()
List1.ListIndex = -1
List2.ListIndex = -1
List3.ListIndex = -1
End Sub
Re: clear selected highlighted for the items in the listbox
Setting ListIndex triggers Click event so what you may need is perhaps check if current ListIndex is -1 and exit if so:
Code:
Private Sub List1_Click()
If List1.ListIndex = -1 Then Exit Sub
List2.ListIndex = -1
List3.ListIndex = -1
List4.ListIndex = -1
End Sub
Private Sub List2_Click()
If List2.ListIndex = -1 Then Exit Sub
List1.ListIndex = -1
List3.ListIndex = -1
List4.ListIndex = -1
End Sub
Private Sub List3_Click()
If List3.ListIndex = -1 Then Exit Sub
List1.ListIndex = -1
List2.ListIndex = -1
List4.ListIndex = -1
End Sub
Private Sub List4_Click()
If List4.ListIndex = -1 Then Exit Sub
List1.ListIndex = -1
List2.ListIndex = -1
List3.ListIndex = -1
End Sub