请问在DELPHI中,如何将窗体上的标签逐个显示出来?

2024-11-24 16:22:26
推荐回答(2个)
回答1:

procedure TForm1.FormCreate(Sender: TObject);
var
i: integer;
begin
for i:= 0 to componentcount - 1 do
begin
application.ProcessMessages;
if (components[i] is TLabel) then
begin
(components[i] as TLabel).Visible := false;
end;
end;
end;

procedure TForm1.Button1Click(Sender: TObject); //触发label显示
var
i: integer;
begin
for i:= 0 to componentcount - 1 do
begin
application.ProcessMessages;
if (components[i] is TLabel) then
begin
sleep(1000); //等待下一条显示时间
(components[i] as TLabel).Visible := true;
end;
end;
end;

回答2:

加一个定时器timer,用时间来控制显示次序