Lazarus

Programming => General => Topic started by: Renato Ricci on November 14, 2019, 07:20:24 pm

Title: How to scroll TFlowPanel?
Post by: Renato Ricci on November 14, 2019, 07:20:24 pm
Hello friends, I am trying to use TFlowPanel component at runtime and add some TPanels inside it. However, the number o TPanels that will be pleced inside TFlowPanel is unkown.. May be 1 and and may be 100 or more.

Is there anyway to automatic show a scrollbar on TFlowPanel when a number of controls inside it exceeds TflowPanel size?

Thanks
Renato
Title: Re: How to scroll TFlowPanel?
Post by: wp on November 14, 2019, 08:19:06 pm
There is a property ControlList from which you can determine the current count of controls inserted (FlowPanel.ControlList.Count); and you can also access the individual controls (FlowPanel.ControlList[0].Control).

The FlowPanel itself does not display scrollbars. But you can insert it into a Scrollbox - that's what this is for. Top-align the FlowPanel inside the ScrollBox, and set its AutoSize to true so that its height adjusts when more controls are added or the scrollbox is resized.

In the attached demo add buttons or edits by means of the buttons. Note that a vertical scrollbar appears when the bottom-most control does not fit into the scrollbox any more.
Title: Re: How to scroll TFlowPanel?
Post by: Renato Ricci on November 14, 2019, 08:57:27 pm
Thanks a lot!

Your example was what I was looking for.

Best regards!
Renato
TinyPortal © 2005-2018