Highlighted Selection in Listboxes

  • Thread starter Thread starter David J.
  • Start date Start date
D

David J.

I would like to highlight desired selection in a list box
based on an event other than clicking it. For example, I
would like to click on a button that highlights/selects
itemdata(0) and itemdata(1).

What would be the syntax used to highlight any item in a
listbox other than clicking in it.

Thanks
Dave J.
 
-----Original Message-----
I would like to highlight desired selection in a list box
based on an event other than clicking it. For example, I
would like to click on a button that highlights/selects
itemdata(0) and itemdata(1).

What would be the syntax used to highlight any item in a
listbox other than clicking in it.

Thanks
Dave J.
.
Hi Dave,

To select a single item in a single select listbox....
lst.value=lst.ItemData(0)

However, make listbox multi-select as you seem to want the
flexibility to select one or more items. Then use the
lst.Selected property to select or unselect items. The
online example is good. You will need to consider
resetting the list of selected items each time.

Luck
Jonathan
 
David said:
I would like to highlight desired selection in a list box
based on an event other than clicking it. For example, I
would like to click on a button that highlights/selects
itemdata(0) and itemdata(1).


I'm not particularly good with list boxes since I use
continuous subforms instead, but this seems to work in a
simple test scenaraio:

Private Sub Command2_Click()
Dim V As Variant
For Each V In List0.ItemsSelected
List0.Selected(V) = False
Next V

List0.Selected(0) = True
List0.Selected(1) = True
End Sub
 
Back
Top