注册 登录
编程论坛 Delphi论坛

有一组Label控件,怎样根据某个整形变量i的大小来改变对应第i个Label控件的Caption啊

xingjiang 发布于 2006-08-22 00:25, 878 次点击
比如现在i=1,则可以改变Label1 的Caption;如果i变成2,就可以改变Label2的Caption,这个功能怎么实现啊,请大侠们帮帮忙啊!!!!!!!!!
2 回复
#2
aikede2006-08-22 15:35
控件数组
#3
ysp_19842006-08-23 17:13
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to self.Componentcount -1 do
begin
if (components[i] is Tlabel) then
(components[i] as Tlabel).Caption:=inttostr(i+1);
end;
end;
1