根据控件类型查找、赋值
以edit为例
//遍历所有控件并置为空。
procedure changeEditTxt;
var
i:integer;
begin
for i := 0 to Self.ComponentCount -1 do
begin
if Self.Components[i] is TEdit then
begin
(Self.Components[i] as TEdit).Text := '';
end;
end;
end;
procedure changeLabelCaption;
var
i:integer;
begin
for i := 0 to Self.ComponentCount -1 do
begin
if Self.Components[i] is TLabel then
begin
(Self.Components[i] as TLabel).Caption := '标签'+inttostr(i);
end;
end;
end;