List box - nothing selected

G

Gary Hillerson

I have a fairly complicated, multi-column list box that's linked to a
data array. This list supports sorting on the columns and deleting
entries from the array, and all is now working fine.

The problem is that sometimes -- and i haven't exactly nailed down
when -- I end up with nothing in the list highlighted; instead,
there's a dotted line around the entry. If the user down-arrows or
up-arrows, the selection moves as expected and the new selection
becomes highlighted.

I can't figure out how to force that entry to be highlighted in these
circumstances. Whenever I redisplay the list (after a new addition,
deletion, or sorting), I explicitly set the listIndex and call
SetFocus on the list control.

Is there something else I need to do or some trick to force the
highlighting?

gary
 
W

Word Heretic

G'day Gary Hillerson <[email protected]>,

set the ListIndex to a meaningful value

Gary Hillerson said:
I have a fairly complicated, multi-column list box that's linked to a
data array. This list supports sorting on the columns and deleting
entries from the array, and all is now working fine.

The problem is that sometimes -- and i haven't exactly nailed down
when -- I end up with nothing in the list highlighted; instead,
there's a dotted line around the entry. If the user down-arrows or
up-arrows, the selection moves as expected and the new selection
becomes highlighted.

I can't figure out how to force that entry to be highlighted in these
circumstances. Whenever I redisplay the list (after a new addition,
deletion, or sorting), I explicitly set the listIndex and call
SetFocus on the list control.

Is there something else I need to do or some trick to force the
highlighting?

gary

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 
G

Gary Hillerson

Actually, the problem was that I was modifying the data source, and
found that I had to first set listIndex to -1, and then set it to a
valid value before it would properly display the currently selected
item as selected.
 

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