十点读书主播波波简介:在delphi中使用了很多相同组件,可以用数组吗?

来源:百度文库 编辑:高考问答 时间:2024/05/03 07:34:54
我要在delphi中做LED点阵,为了便于操作,想用数组,请问怎么运作啊?

完全可以. 不过就不能在设计时用, 必须是在运行时动态生成, 比如:
var
btns: array[1..10] of TButton;
begin
for n := 1 to 10 do
begin
btns[n] := TButton.Create(Self);
btns[n].Caption := ...;
btns[n].Left := ...;
...
end;
...
end;

大概就是这个意思吧

delphi我不是很了解,但是在VB中是可以使用控件数组的,同是WIN32的开发工具,相信delphi应该也可以用。

可以,
lb1Content:array[1..13] of Tlabel;
for j:=1 to 10 do
begin
lb1Content[j]:=Tlabel.create(self);
lb1Content[j].Parent :=form1;
lb1Content[j].Caption :='ffff';
lb1Content[j].Left :=250+j*4;
lb1Content[j].Top :=200+j*5;
end;