How to delete all items of a TFlowLayout at runtime?

231 Views Asked by At

I want to clear a FlowLayout at run time, is there a function to do that ? I thought about mapping all its items and free theme, but I don't know how to access its items, any code example please ?

1

There are 1 best solutions below

0
Tom Brunberg On BEST ANSWER

Using the Children and ChildrenCount properties you can free the items, either in reverse order

for i := FlowLayout1.ChildrenCount-1 downto 0 do
  FlowLayout1.Children[i].Free;

or in forward order (repeatedly addressing item with index 0)

for i := 0 to FlowLayout1.ChildrenCount-1 do
  FlowLayout1.Children[0].Free;