要像VB那样由编译器支持的话就不行,可以这样:
A: array [0..10] of TLabel;for i := 0 to 10 do
A[i] := TLabel.Create(Form1);
A[i].Parent := Form1;
end;
A: array [0..10] of TLabel;for i := 0 to 10 do
A[i] := TLabel.Create(Form1);
A[i].Parent := Form1;
end;
解决方案 »
- 50 简单问题,DLL里如何头部申明...............
- Inno Setup打包NT服务程序安装时报错("faild to install with error 指定服务已存在! ")
- 关于将两个变量保存到一起
- 怎么把webbrowser设成不可见?
- 如果有两个光驱,要打开第二个光驱,请问程序怎样写?
- 在Notebook控件中,怎么得到当前页(或指定的某页)中的所有控件信息!
- 如何将c/s结构的系统,转换为多层结构
- 请问如何在BDedit中修改数据?
- 又出问题了!!!!!!!1
- 难道开发OA系统一定要用Loutus吗?
- 怎样对MemItem排序?----- 最近脑子糊涂,那位清楚的仁兄帮我?
- 如何在Delphi中不使用VCL库建立窗口?
a:=findcomponent('label'+inttostr(i));
if assigned(a) then
Tlabel(a).caption:='label'+inttostr(i);
i:integer=1;
begin
while i<=100 do
begin
mylabel[i]:=Tlabel.create(self);
mylabel[i].parent:=form1;
mylabel[i].caption:='kk+inttostr(i)';
mylabel[i].onclick:=myclick;
inc(i);
end;
end;
var A: array [0..10] of TLabel;
begin
a[0]:=label1;
a[1]:=label2;
.
.
.
a[10]:=label10;
end;
以后用a就可以了
public
Labels1:Array of TLabel;在TformMain.FormCreate(OnCreate事件)中:
begin
……
SetLength(Labels1,LabelNum);
for i := 0 to LabelNum-1 do
begin
Labels1[i] := TLabels.Create(self);
InsertControl(Labels1[i]);
Labels1[i].Visible:=true;
Labels1[i].X=……
Labels1[i].Y=……
Labels1[i].Caption=……
……
end;
……
end;
在Delphi中不能象VB那样在设计时把一组控件作为一个数组放到Form上,只能编写代码在运行时生成。
你应该详细说明你要作什么,一般来说Label数组用处不大,在VB中控件数组主要用于多个控件使用相同的事件代码,在Delphi中只要把它们的事件设为相同的函数就行了。