Auto scrolling in a list box

I have a list box that stores a list of user names.  The form gives the option of viewing the names either by the NT Logon name (ie PHIGGINS) or by Last Name, First Name (ie Higgins, Peter).

I've got code that switches between them fine and the same user remains selected.  The problem I'm having is that the list box doesn't scroll to show the name, so the user can't see that it is selected.  For instance, if the first 20 names are shown in the list box and one is selected and then the display is changed, because the listbox is sorted, that name may be the 50th in the list, but the listbox still only shows the first 20 and the user has to scroll down to see the selected name.

Is there any way to make a listbox automatically scroll to show a selected entry?
LVL 3
peteyhigginsAsked:
Who is Participating?
 
TimCotteeConnect With a Mentor Head of Software ServicesCommented:
If you set the .TopIndex = .ListIndex for the list box then the selected row should be shown at the top of the list.
0
 
nigelroweCommented:
Yep, just put that code in the Click event of the list box
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.