// in public or private
var Labels : array [1..2] of TLabel;
// in OnFormCreate or similar event
begin
Labels[1] := Label1;
Labels[2] := Label2;
end;
// somewhere else
var
lLabel : TLabel;
begin
for lLabel in Labels do lLabel.Caption := 'xyz';
end;
1.使用当前表单的TForm.Control数组:
var
I : integer;
lControl : TControl;
begin
for I := 0 to ControlCount-1 do
begin
lControl := Controls [I];
if lControl is TLabel then (lControl as TLabel).Caption := 'xxx';
end;
end;
1条答案
按热度按时间nwnhqdif1#
如果使用IDE创建标签,则有两个选择:
1.使用您自己的数组:
1.使用当前表单的
TForm.Control
数组: