Discussion:
How do I 'scroll' the ListBox to the last Row (within a loop) ?
Emile Schwarz
2005-06-13 10:25:13 UTC
Permalink
Hi,


REALbasic 5.5.5
Mac OS X 10.4.1


I do not care to read the last added Row, but after some times using that prart
of the project waiting without 'user feedback', I decided - before lunch today -
to make the last Row visible.

Sorry, I forget one thing: there is a loop who takes a text file, scan its
contents, take the relevant (for me) information and display them (two Columns)
in a ListBox. Before today changes, the only user feedback was the vertical
ScrollBar - at the beginning - who grow (or shrink depending on what part of the
ScrollBar you're looking at) until no change happens. And you wait, wait, wait
(or do something else until the data scan is done).

Now, I can go ahead on 'How do I scroll the ListBox to display the last Row ?'.

In a (far distant) REALbasic version, I do that, but since my archives are not
available, I had to start from the beginning.

Try #1:
-------
My first idea was simple: I know the number of Rows (ListBox.ListCount), the Row
Height (ListBox.DefaultRowHeight), I only have to compute the value:

YPosition = ListBox.ListCount * ListBox.DefaultRowHeight

But this does not works, ListBox.DefaultRowHeight = -1 by default.


Try #2:
-------
No problemo: I only have to use ListBox.TextSize (there can be a small error,
but I can work-around that addind 1 pixel or two to the ListBox.TextSize).

But this does not works, ListBox.TextSize = 0 by default. (here, because I set
zero to be XPlatform compliant).


Try #3:
-------
No problemo: I only have to use 12 - for 12 pixels - (there can be a small
error, but I can work-around that using 13 or 14...).

This does works, but I have to be XPlatform compliant and to add #If Target ...
/ ... #Else and so on... too many bucks for the bang. :(


Try #4:
-------
What if I use a 'by default large' number (in a constant) and pass this value to
ListBox.ScrollPosition ?

As soon as I thank at that, I implemented it.

Result:

Hey, this works fine... but slow down the whole operation (I suspected that, so
this is not a surprise). The scrollbar inside blue object (don't remember the
official name, I call than the 'ascinter' think 'lift') is now located on the
bottom part of the ScrollBar and I see that the Rows are... scrolling to the top.


Try #5:
-------
What about using a ChasingArrows Control in a small window that I open at the
start of the Loop (before For ...) and close at the end of the Loop (after
Next...) ?


NOW THE QUESTION:
What solution did you try ?
[one of the above or one I didn't think at - for the moment - ?]

More information:
The test file size weight 380KB and fills 300 Rows. I do not know the typical
number of generated Rows (lines), but I think that less than 600KB was the
largest (html with embedded JavaScript) source file; that let me think at around
600 Rows (lines).


TIA,

Emile


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
Tom
2005-06-13 11:55:44 UTC
Permalink
Post by Emile Schwarz
Now, I can go ahead on 'How do I scroll the ListBox to display the last Row ?'.
Um... does
ListBox1.ScrollPosition = ListBox1.ListCount
not work?

Cheers,

Tom
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
Emile Schwarz
2005-06-13 14:36:08 UTC
Permalink
Are-you telling me that ListBox1.ScrollPosition arg is a Row # and not a Y
position in Pixel ?

If so, the RB 5.5.5 language reference description is bad enought to me that I
misunderstand...

I was thinking that I have to put a vertical value...

TIA,

Emile
Message: 20
Subject: Re: How do I 'scroll' the ListBox to the last Row (within a loop) ?
Date: Mon, 13 Jun 2005 13:55:44 +0200
Post by Emile Schwarz
Now, I can go ahead on 'How do I scroll the ListBox to display the
last Row ?'.
Um... does
ListBox1.ScrollPosition = ListBox1.ListCount
not work?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
Tim Jones
2005-06-13 15:38:45 UTC
Permalink
Post by Emile Schwarz
Are-you telling me that ListBox1.ScrollPosition arg is a Row # and not
a Y position in Pixel ?
Yep - Tom is correct. But, I was in the same position that you were in
by assuming the LR implied pixels, not rows. So, change my logic
example to:

ListBox1.AddRow "A New Row"
If ListBox1.LastIndex Mod 10 = 0 Then
ListBox1.ScrollPosition = ListBox1.ListCount
ListBox1.Refresh
ChasingArrows1.Refresh
End If

Tim
--
Tim Jones tjmac-Gm3gQj5Kd2+***@public.gmane.org

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Tim Jones
2005-06-13 15:32:52 UTC
Permalink
Post by Emile Schwarz
-------
What if I use a 'by default large' number (in a constant) and pass
this value to ListBox.ScrollPosition ?
As soon as I thank at that, I implemented it.
Hey, this works fine... but slow down the whole operation (I suspected
that, so this is not a surprise). The scrollbar inside blue object
(don't remember the official name, I call than the 'ascinter' think
'lift') is now located on the bottom part of the ScrollBar and I see
that the Rows are... scrolling to the top.
How about a combinatoin of updating and a chasingarrows control and
only updating the ScrollPosition every 10th row added? Since you know
that there will most likely be no more than 300 entries, use the
following type of logic after your listbox.addrow call (I've included
an entire test function, so edit as needed):


Dim x As Integer

ChasingArrows1.Visible = True
for x = 1 to 300
ListBox1.AddRow "A New Row"
// This is the logic to implement
If ListBox1.LastIndex Mod 10 = 0 Then
ListBox1.ScrollPosition = 300 * 18 // Change to your determined
row height
ListBox1.Refresh
ChasingArrows1.Refresh
End If
Next
ListBox1.ScrollPosition = 300 * 18
ListBox1.Refresh
ChasingArrows1.Visible = False

HTH,

Tim
--
Tim Jones tjmac-Gm3gQj5Kd2+***@public.gmane.org


_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
Loading...