David P 3 Posted July 10, 2023 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
programmerdelphi2k 237 Posted July 10, 2023 (edited) @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 July 10, 2023 by programmerdelphi2k Share this post Link to post
David P 3 Posted July 10, 2023 (edited) 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 July 10, 2023 by David P Share this post Link to post
programmerdelphi2k 237 Posted July 10, 2023 (edited) 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 first, define the Parent later, define align=none 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) re-define align to Top or Bottom Edited July 10, 2023 by programmerdelphi2k Share this post Link to post
David P 3 Posted July 19, 2023 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