Jump to content
David P

TScrollBox contents order

Recommended Posts

For our application, we used to add new items to the bottom of the scrollbox so they're in chronologcal order (top=oldest). We were able to do this by setting all the child forms with Align=alTop and Top to be further down the screen.  This worked. Random child forms could be destroyed and the contents would shuffle up, retaining their order.

 

Possibly with the introduciton of 11.3, this changed.  No matter what I now do, items are always inserted at the top.  I don't want to have recreate all the contents of the scrollbox to get my desired order as a user may be interacting with a child form higher up in the scroll box.

 

Does anyone know how to add items to the bottom of a scroll box?

 

Thanks

 

David

Share this post


Link to post

@David P

 

did you try, before insert the items, define the property position "Y" (or X if horizontally), before that define the "alingment"?

for example:   -(value out of screen) (negative or positive) value to position?

Edited by programmerdelphi2k

Share this post


Link to post

Yes, I calculate the height of the current contents, then set NewChild.Top = HeightofCurrentContents + 50, so the Top should be below everything currently contained in the scrollbox.  Similar to:

 

NewChild.Top = HeightofCurrentContents + 50;

NewChild.Parent = myScrollbox;

NewChild.Align = alTop;

NewChild.Show();

 

This has worked for ~20 years, but with the same code, stopped working a few months back. The only thing I can think changed was upgrading to 11.3 gtom 11.2

Edited by David P

Share this post


Link to post
25 minutes ago, David P said:

NewChild.Top = HeightofCurrentContents + 50;

NewChild.Parent = myScrollbox;

NewChild.Align = alTop

sometimes, it's necessary ALIGN = NONE!!! then with your "PARENT" defined, now you can put on the position out this control! you see? after this, you can (again) re-align to TOP or BOTTOM, as you need

  1. first, define the Parent
  2. later, define align=none
  3. position=x  (out this control, maybe   xControl.Top (absolute position on screen) + xControl.Height + NNNN)  -> if your xControl is into a another control, use this control-parent to get the values)
  4. re-define align to Top or Bottom
Edited by programmerdelphi2k

Share this post


Link to post

Thanks for your reply (I've been on holiday).

 

I followed your line of reasoning and was able to determine for my vertical TScrollBox:

 

Child.Top - setting this has no effect on positioning in the TScrollBox

 

If Align = alNone, all child windows will overlap at the top of the TScrollBox

 

TScrollBox seems to purely use Child.Align to place windows.

 

I was able to make this work by using:

 

Child.Parent = MyScrollBox

Child.Align = alBottom

Child.Show( )

Child.Align = alTop

 

New entries will now appear at the bottom of the stack.

 

 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×