Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread How to clear the control collection on a TPanel?
Wed, Feb 7 2018 12:43 PMPermanent Link

Mario Enríquez

Open Consult

Hi folks,

Is there a quick way to clear the controls collection inside a TPanel?

I've a rutine that dynamically creates TBasicPanel's inside a TScrollPanel at runtime, but I'm having a hard time to find a way to remove the contents of the owner when it comes the time to refresh and populate the content.

I've read the manual, but couldn't find a solution yet...

Regards,
Mario
Wed, Feb 7 2018 2:54 PMPermanent Link

Uli Becker

Mario,

<<
Is there a quick way to clear the controls collection inside a TPanel
>>

for i = container.controlcount - 1 down to 0 do
  container.controls[i].free;

Uli
Thu, Feb 8 2018 4:24 AMPermanent Link

Matthew Jones

Uli Becker wrote:

> <<
> Is there a quick way to clear the controls collection inside a TPanel
> > >
>
> for i = container.controlcount - 1 down to 0 do
>    container.controls[i].free;
>
> Uli

Indeed, my complete routine:

procedure ClearPanel(xClearPanel : TControl);
var
   i: integer;
   c: TComponent;
begin
   for i := xClearPanel.ControlCount - 1 downto 0 do
   begin
       c := xClearPanel.Controls[i];
       c.free;
   end;
end;


--

Matthew Jones
Fri, Feb 9 2018 8:44 AMPermanent Link

Mario Enríquez

Open Consult

Thank you Uli and Mathew

Regards,
Mario
Image