Answer the question
In order to leave comments, you need to log in
How to remove dynamically created Delphi fmx components?
Hi guys! I fight with the task I can not understand. There is a data file in txt in the form of a list; elements in the form are created on it. vertscrollbox1.
Those.
I create it like this: (I'm writing from the phone, sorry)
Var
Panel: Tpanel;
Begin
Panel:=Tpanel.create(form)
Panel.parent:=Vertscrollbox1
Parameters
Parameters
End;
Everything is created, Everything is good. But how to clean up Vertsrollbox1 from them and recreate the components programmatically?
Tried just about anything. And free, destroy, destroycomponents and searched for each by name, All solutions either hang and nothing happens or kill the Vertsrollbox on the form. Can you please tell me how it works with the components????
Answer the question
In order to leave comments, you need to log in
Read carefully
yaroslavbrovin.ru/object_life_cycle_in_delphi_part...
yaroslavbrovin.ru/object_life_cycle_in_delphi_part...
Vertscrollbox1.DeleteControl ? or RemoveControl
There are two differences.
1) Remove the component from the form panel
2) Remove from memory.
Everything is completely removed
var
pArray: array[0..10] of TPanel;
procedure TForm2.Button1Click(Sender: TObject);
var
I: Integer;
panel: TPanel;
begin
for I := 0 to 9 do
begin
Panel:=Tpanel.create(form2);
Panel.parent:=Vertscrollbox1;
pArray[i] := panel;
end;
end;
procedure TForm2.Button2Click(Sender: TObject);
var
I: Integer;
begin
for I := 0 to 9 do
begin
FreeAndNil(pArray[i]);
end;
end;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question