Highlighted Selection in Listboxes

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.
 
J

Jonathan Parminter

-----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
 
M

Marshall Barton

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top