如果你想给你form上许多个label赋值,一般这样做:
for i := 0 to self.ComponentCount - 1 do
begin
if self.Components is Tlabel then
Tlabel(self.Components).caption:='hello';
end;
var
c: TComponent;
beign
for i := 0 to ComponentCount - 1 do
begin
c := FindComPonent('Label' + IntToStr(i));
if (c<>nil) and (c is TLabel) then TLabel(c).Caption:='hello';
end;
end;