ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting focus on User Form Listbox (https://www.excelbanter.com/excel-programming/371397-setting-focus-user-form-listbox.html)

Don Wiss

Setting focus on User Form Listbox
 
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).

Dave Peterson

Setting focus on User Form Listbox
 
Maybe...
lbxTerr.topindex = i
or maybe
lbxOtherLB.topindex = lbxTerr.topindex



Don Wiss wrote:

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


--

Dave Peterson

Don Wiss

Setting focus on User Form Listbox
 
On Thu, 24 Aug 2006, Dave Peterson wrote:

Don Wiss wrote:
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?


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

Dave Peterson

Setting focus on User Form Listbox
 
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
--

Dave Peterson

Don Wiss

Setting focus on User Form Listbox
 
On Fri, 25 Aug 2006, Dave Peterson wrote:

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.


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


All times are GMT +1. The time now is 01:28 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com