Highlighting first line in list box

K

kirkm

Could someone please explain how to consistently set the first
item in the list box to selected (i.e. highlit) without needing to
click on it?

I've tried

List1.Selected(0) = True
and
list1.listindex = 0

Both *seemed* to work, but occasionaly fail.

Thanks - Kirk

PS it's not a MultiSelect listbox.
 
K

kirkm

Hi,

Do you put the focus on the listBox ?
Regards
JY

Hi JY,

Thanks for that suggestion, I've just applied it and not had a failure
in 10 or 20 goes. I had assumed the listbox *would* have the focus in
it's own Enter event.

Private Sub List1_Enter()
List1.SetFocus <<<< New line
List1.Selected(0) = True
End Sub

I proved List1.Selected was working as substituting another number
for (0) sees the slection change to that line. Why it sometimes
didn't work I couldn't figure.... hope this fixes it.

Thanks - Kirk
 

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