呵呵,可惜delphi没有控件数组〉。 给你2个方法: 1.如果知道各Label的name,那末就挨个写吧:P 2.如果不知道,可以历遍所有Tlabel控件 for i:=0 to ComponentCount-1 do begin if Components[i] is TLabel then begin TLabel(Components[i]).Caption:='标签文字'; end; end;当然你也可以用所有Label的Tag来标识控件,在上面判断就成了
for i:1 to form1.componentcount-1 do begin if form1.components[i] is tlabel then begin (form1.components[i] as tlabel).caption:='label'+inttostr(i); end; End;
给你2个方法:
1.如果知道各Label的name,那末就挨个写吧:P
2.如果不知道,可以历遍所有Tlabel控件 for i:=0 to ComponentCount-1 do
begin
if Components[i] is TLabel then
begin
TLabel(Components[i]).Caption:='标签文字';
end;
end;当然你也可以用所有Label的Tag来标识控件,在上面判断就成了
begin
if form1.components[i] is tlabel then
begin
(form1.components[i] as tlabel).caption:='label'+inttostr(i);
end;
End;