for i:=1 to n do with tlabel(findcomponent('label'+inttostr(i))) do caption:=inttostr(i);
procedure Tform1.Button1Click(Sender: TObject); var i:integer; begin with form1 do for i:=0 to ComponentCount-1 do begin if (Components[i] is Tlabel) then begin (Components[i] as Tlabel).cattion:=inttostr(i); end; end; end;
for i:= 0 to aForm.ComponentCount- 1 do begin if aForm.Components[i] is TLabel then begin (aForm.Components[i] as TLabel).Text:= '';//属性控制 end; end;
for i:=0 to componentcount-1 do if components[i]is tedit then begin end;
首先同意楼上的。 可以把这些控件装到一个容器中,例如groupbox 然后 for i:=0 to GroupBox.ControlCount-1 do begin if GroupBox.Controls[i].ClassType=TLable then TLabel(GroupBox.Controls[i]).Caption:='ok'; end;
procedure Tform1.Button1Click(Sender: TObject); var i:integer; begin with form1 do for i:=0 to ComponentCount-1 do begin if (Components[i] is Tlabel) then begin (Components[i] as Tlabel).cattion:=inttostr(i); end; end; end;
with tlabel(findcomponent('label'+inttostr(i))) do
caption:=inttostr(i);
var
i:integer;
begin
with form1 do
for i:=0 to ComponentCount-1 do
begin
if (Components[i] is Tlabel) then
begin
(Components[i] as Tlabel).cattion:=inttostr(i);
end;
end;
end;
begin
if aForm.Components[i] is TLabel then
begin
(aForm.Components[i] as TLabel).Text:= '';//属性控制
end;
end;
if components[i]is tedit then
begin
end;
可以把这些控件装到一个容器中,例如groupbox
然后
for i:=0 to GroupBox.ControlCount-1 do
begin
if GroupBox.Controls[i].ClassType=TLable then
TLabel(GroupBox.Controls[i]).Caption:='ok';
end;
var
i:integer;
begin
with form1 do
for i:=0 to ComponentCount-1 do
begin
if (Components[i] is Tlabel) then
begin
(Components[i] as Tlabel).cattion:=inttostr(i);
end;
end;
end;