有分大家分点:
var
I: Integer;
Instance: TControl;
begin
I := ControlCount;
while I <> 0 do
begin
Instance := Controls[I - 1];
RemoveControl(Instance);
Instance.Destroy;
Instance:=nil;
I := ControlCount;
end;
end;
//sorry,miss with sentence:
var
I: Integer;
Instance: TControl;
begin
I := ControlCount;
with panel1 do
begin
while I <> 0 do
begin
Instance := Controls[I - 1];
RemoveControl(Instance);
Instance.Destroy;
Instance:=nil;
I := ControlCount;
end;
end;
end;