List Box issue

  • Thread starter Thread starter Jasper Recto
  • Start date Start date
J

Jasper Recto

I have a little program that has several list boxes. If I click on an item
in one list box, it highlights the selection. If I click on another item in
a DIFFERENT list box, it highlights that selection. The problem is, the 1st
item chosen is still highlighted. If I have 6 list boxes, I could
potentially have 6 items highlighted. How do you have the current selection
be the only item highlighted and all other items in the other list boxes not
be highlighted?

Thanks,
jasper
 
Jasper,

The selected items within different listviews are independent and there is
no built in functionality to link these items. What you can do however is
create an event handler that handles the click event for all four
listviews. Then what you could do in your event handler is identify which
listview was clicked on and then unselect the selected items for the
listboxes that were not clicked.

So, somewhere within your initialization code you'd wire up the events:

AddHandler ListView1.Click, AddressOf ListView_Clicked
AddHandler ListView2.Click, AddressOf ListView_Clicked
AddHandler ListView3.Click, AddressOf ListView_Clicked
AddHandler ListView4.Click, AddressOf ListView_Clicked

And then you'd have the event handler:

Private Sub ListView_Clicked(ByVal sender As System.Object, ByVal e As
System.EventArgs)
If Not CType(sender, ListView).Name = "ListView1" Then
ListView1.Clear()
End If

If Not CType(sender, ListView).Name = "ListView2" Then
ListView2.Clear()
End If

If Not CType(sender, ListView).Name = "ListView3" Then
ListView3.Clear()
End If

If Not CType(sender, ListView).Name = "ListView4" Then
ListView4.Clear()
End If
End Sub




Thanks! Robert Gruen
Microsoft, VB.NET

This posting is provided "AS IS", with no warranties, and confers no rights.
 
Back
Top