Results 1 to 2 of 2

Thread: [RESOLVED] clear selected highlighted for the items in the listbox

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2007
    Location
    Malaysia
    Posts
    1,370

    Resolved [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
    Last edited by matrik02; Feb 16th, 2008 at 10:03 PM.

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width