Setting focus on User Form Listbox

D

Don Wiss

I have a Listbox on a User Form. Another form has gotten the user's
selection. I then transfer their selection to this Listbox with:

lbxTerr.Selected(i) = True

But the focus inside the Listbox is still on the first item. This isn't a
big deal, but I'd rather not have the faint dashed line around the first
selection. So what puts the focus on the item that I just set to true?

Don <www.donwiss.com> (e-mail link at home page bottom).
 
D

Dave Peterson

Maybe...
lbxTerr.topindex = i
or maybe
lbxOtherLB.topindex = lbxTerr.topindex
 
D

Don Wiss

Maybe...
lbxTerr.topindex = i

I tried this. While it didn't move the focus, it did bring into view the
selection when it was not in view. So it was a very useful addition. I
ended up not running it when the selection was in view. I could have, and
that would have pushed the faint dashed line out of view.
or maybe
lbxOtherLB.topindex = lbxTerr.topindex

I didn't figure out just what this suggestion was.

I communicated a bit with the support place my company hires. He determined
it would require APIs and finding the handle. Way overkill for what is
basically a cosmetic issue.

Don <www.donwiss.com> (e-mail link at home page bottom).
 
D

Dave Peterson

or maybe
lbxOtherLB.topindex = lbxTerr.topindex

I didn't figure out just what this suggestion was.

If lbxTerr showed element N, I thought that maybe you wanted to have your other
listbox (delightfully named lbxOtherLB) to show the same.



Don Wiss wrote:
<<snipped>>
 
D

Don Wiss

I didn't figure out just what this suggestion was.

If lbxTerr showed element N, I thought that maybe you wanted to have your other
listbox (delightfully named lbxOtherLB) to show the same.

There is no other listbox. The zip code selection form has closed and it
passes the state and territory to the main form. State is a combo box. A
change event on it populates the territory listbox. Then it selects the
territory that the entered zip code falls into.

Don <www.donwiss.com> (e-mail link at home page bottom).
 

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