Recent

Author Topic: How to scroll TFlowPanel?  (Read 145 times)

Renato Ricci

  • New Member
  • *
  • Posts: 10
    • Emissor NFe | Sistema Emissor NFe Web | Automação Comercial | Sat CFe NFe
How to scroll TFlowPanel?
« 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

wp

  • Hero Member
  • *****
  • Posts: 6459
Re: How to scroll TFlowPanel?
« Reply #1 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.
« Last Edit: November 14, 2019, 08:40:33 pm by wp »
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

Renato Ricci

  • New Member
  • *
  • Posts: 10
    • Emissor NFe | Sistema Emissor NFe Web | Automação Comercial | Sat CFe NFe
Re: How to scroll TFlowPanel?
« Reply #2 on: November 14, 2019, 08:57:27 pm »
Thanks a lot!

Your example was what I was looking for.

Best regards!
Renato