Why does TFramedScrollBox always return number of controls as 2 only in FMX?

139 Views Asked by At

I have to know number of controls placed inside a TFramedScrollBox control container.

When I use the code TFramedScrollBox.ControlsCount. It always return the value 2. Why?

I want to use the for loop and iterate through each control and set a few properties. As the number of controls returned is always 2 I am not able to iterate through each control contained inside TFramedScrollBox.

How to solve this problem?

1

There are 1 best solutions below

2
On BEST ANSWER

The FMX TFramedScrollBox (as well as TScrollBox) has a property Content: TScrollContent which holds the added controls. Use Content.Controls to list the controls.

For example:

for i := 0 to FramedScrollBox1.Content.ControlsCount-1 do
  Memo1.Lines.Add(FramedScrollBox1.Content.Controls[i].Name);

Edit:

To answer the question "why TFramedScrollBox.ControlsCount always returns 2?:

The two components indicated by TFramedScrollBox.ControlsCount and which can be accessed via TFramedScrollBox.Controls are a TLayout and a TScrollContent. The latter being the Content that holds the child controls.