New topic: 

Listbox scroll question

<http://forums.realsoftware.com/viewtopic.php?t=46725>

         Page 1 of 1
   [ 6 posts ]                 Previous topic | Next topic          Author  
Message        jerryab          Post subject: Listbox scroll questionPosted: 
Sun Jan 27, 2013 5:55 pm                         
Joined: Mon Dec 12, 2011 7:25 pm
Posts: 159
Location: Grand Rapids MI Area                I have a listbox with lets say 
100 items listed in it.

I command the listbox to an item in the listbox and it gets highlighted.

The listbox is only high enough to show 15 of the 100.

The item highlighted is at the bottom of the list out of view.

Is there a way to bring into view (scroll up/down) the item that is
highlighted in the listbox when it is commanded without having to
manually scroll up or down to see it ?      
_________________
iMac 27" (2.8GHz Intel Core i5, 16GB RAM, 1TB Drive) OS X Lion 10.7.3 and 
Windows 7
Toshiba Laptop Running Windows 7 & WinXP SP3
REAL Studio Enterprise Edition 2012r1
http://www.theultimatecampgroundlog.com
Being rewritten for the Mac  
                             Top                HMARROQUINC          Post 
subject: Re: Listbox scroll questionPosted: Sun Jan 27, 2013 6:15 pm            
                     
Joined: Sun Jan 25, 2009 5:11 pm
Posts: 376
Location: Guatemala, Central America                Something like this:

dim i as integer

for i = 1 to 100
  listbox1.AddRow("Row: " + str(i))
next i
listbox1.selected( listbox1.ListCount -1) = true
listbox1.ScrollPosition = listbox1.ListCount -1
      
_________________
Future RS guru.
Ride the world!  
                             Top                timhare          Post subject: 
Re: Listbox scroll questionPosted: Sun Jan 27, 2013 6:17 pm                     
    
Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12029
Location: Portland, OR  USA                Set ListBox.ScrollPosition to some 
appropriate value, depending on how you want the data displayed.  For example, 
you might do something like:
Listbox1.ListIndex = X
if X < 8 then
  Listbox1.ScrollPosition = 0 // top of list
elseif X > Listbox1.ListCount - 8 then
  Listbox1.ScrollPosition = Listbox1.ListCount - 15  // end of list
else
  Listbox1.ScrollPosition = X - 7 // center the row in the list display
end
   
                             Top                ktekinay          Post subject: 
Re: Listbox scroll questionPosted: Sun Jan 27, 2013 6:20 pm                     
            
Joined: Mon Feb 05, 2007 5:21 pm
Posts: 411
Location: New York, NY                Use ScrollPosition, and I recommend that 
you use the selected item minus 1. For example:
lb.Selected( row ) = true
lb.ScrollPosition = row - 1

This will bring it into view, but not make it the topmost item. You can even 
get fancy with RowFromXY to see if the row is already visible before forcing a 
scroll.      
_________________
Kem Tekinay
MacTechnologies Consulting
http://www.mactechnologies.com/

Need to develop, test, and refine regular expressions? Try RegExRX.
  
                             Top                HMARROQUINC          Post 
subject: Re: Listbox scroll questionPosted: Sun Jan 27, 2013 6:43 pm            
                     
Joined: Sun Jan 25, 2009 5:11 pm
Posts: 376
Location: Guatemala, Central America                This guys had to get all 
fancy 

But fancy is good.      
_________________
Future RS guru.
Ride the world!  
                             Top                jerryab          Post subject: 
Re: Listbox scroll questionPosted: Sun Jan 27, 2013 6:54 pm                     
    
Joined: Mon Dec 12, 2011 7:25 pm
Posts: 159
Location: Grand Rapids MI Area                Thanks guys. Problem solved with 
one line of code added to what I had already.

Fast responses. WOW....      
_________________
iMac 27" (2.8GHz Intel Core i5, 16GB RAM, 1TB Drive) OS X Lion 10.7.3 and 
Windows 7
Toshiba Laptop Running Windows 7 & WinXP SP3
REAL Studio Enterprise Edition 2012r1
http://www.theultimatecampgroundlog.com
Being rewritten for the Mac  
                             Top             Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 6 posts ]      
-- 
Over 1500 classes with 29000 functions in one REALbasic plug-in collection. 
The Monkeybread Software Realbasic Plugin v9.3. 
http://www.monkeybreadsoftware.de/realbasic/plugins.shtml

rbforumnotifier@monkeybreadsoftware.de

Reply via email to