Scrollig SelectedItem in LB (1 Viewer)

richard luft

Registered User.
Local time
Yesterday, 20:01
Joined
Jun 4, 2004
Messages
63
Scrolling SelectedItem in LB in code

Hi: Anyone know if there is any way to make a selecteditem in a listbox move so that it is 'scrolled' to the top of the visible listbox. I'd like to add such a feature to a filltree type of listbox outline.
TIA, Richard
 
Last edited:

garyca

New member
Local time
Today, 13:01
Joined
Nov 12, 2003
Messages
6
I'm trying to do this as well. It seems the control can't do this.
 

skea

Registered User.
Local time
Today, 06:01
Joined
Dec 21, 2004
Messages
342
Use a For loop and listindex.
It may not need to show on top, as long as its selected into visibility.
 
Last edited:

skea

Registered User.
Local time
Today, 06:01
Joined
Dec 21, 2004
Messages
342
I forgot to point out. For you to ahieve this, you will need to setFocus to the listbox.
 

richard luft

Registered User.
Local time
Yesterday, 20:01
Joined
Jun 4, 2004
Messages
63
Glad that GARYCA responded to my msg so as to get the string going! Note that I posted the Q back in June.
Now all I have to do is see if I can figure out what the respondents mean. Thanks.
Richard
 
Last edited:

skea

Registered User.
Local time
Today, 06:01
Joined
Dec 21, 2004
Messages
342
I think i saw your Qtn way back before i tried it out myself.
But to get you right, when you look in the screenshots thread in the samples forum, i implement this in my database reporter.
I search for something, then the listbox scrolls it in visibility. Is that what you meant?
If so try it out and respond if you still need help.We had a Listbox class posted in the samples forum before the hack,but now its long gone, but it would be of help to you. If you need it, i have a copy, i can post it back.
 
Last edited:

richard luft

Registered User.
Local time
Yesterday, 20:01
Joined
Jun 4, 2004
Messages
63
Skea;
"I search for something, then the listbox scrolls it in visibility. Is that what you meant?"
>>>>>>
No. I have a listbox which is filled by a 'filltree' fn. There are many branches in my tree. When I 'select' an item in the tree to open up the branches for that selection, I'd like my selection to scroll to the top of the lb, so there is now room for me to see the branches of the tree in the lb beneath the selection. Then, when I select the next branch, I'd like it again to scroll to the top, so that I can again have room to view the branches.
Thus, I'm not 'searching' for a particular item.
Does this make my need clear?
I'll look in samples to see what you mean.
Richard
 
Last edited:

richard luft

Registered User.
Local time
Yesterday, 20:01
Joined
Jun 4, 2004
Messages
63
RURALGUY;
Info looks like it might help. I'm not sure, however, if there will be any advantage to a command btn in place of scrolling the lb itself. Hope I can figure out some way to auto-actuate.
Richard
 

RuralGuy

AWF VIP
Local time
Yesterday, 21:01
Joined
Jul 2, 2005
Messages
13,826
I'll bet you can! If not, post back with the code you tried and I'm sure someone will help.
 

richard luft

Registered User.
Local time
Yesterday, 20:01
Joined
Jun 4, 2004
Messages
63
Steve Lebans code works great. I'm actuating an auto effect by setting focus on a transparent command button (on double-click of item selected in lb), and using SendKeys "~" to effect the code on the command button.
Two questions for the audience:
1)anyone have any suggestions as to how I can avoid using SendKeys?
2) I tried importing my functioning form into another Db, and find that I get an errmsg of "sub or function not defined" related to the code line :
LngThumb = MakeDWord(SB_THUMBPOSITION, CInt(LngIndex)), with "MakeDWord" highlighted.
Any suggestions as to what could be causing this problem?
TIA, Richard
 

RuralGuy

AWF VIP
Local time
Yesterday, 21:01
Joined
Jul 2, 2005
Messages
13,826
I haven't really studied Stephan's code but you can call the code of a Command Button in VBA without SendKeys.
Call CommandButton1_Click() using the name of your command button of course.
 

Users who are viewing this thread

Top Bottom