procedure TForm1.Button1Click(Sender: TObject);
var
i: Integer;
FreeButton: TButton;
begin
for i := 0 to Application.ComponentCount - 1 do
begin
FreeButton := TButton(FindComponent('button2'));
if FreeButton <> nil then
FreeButton.Free;
end;
end;
var
aa: tedit;
begin
aa := tedit.create(self);
aa.parent := self;
aa.text := 'aaaa';
end;
或
with tedit.create(self) do
begin
parent := self;
text := 'aaaa';
end;