如果在运行期才知道
要动态分配多少个控件,比如说count个lable控件想用一条for语句实现

for i:=0 to count do
begin
   :=Tlable.Creat(Form1);
......
end;
可是delphi里没有控件数组
我即使定义了mlable1,mlable2也没用
请问该怎么解决啊

解决方案 »

  1.   

    var
      Slable:array[1..10] of Tlable;
      i:=integer;
    begin
      for i:=1 to 10 do
        begin
          Slable[i]:=Slable.create(self);
          Slable[i].parent:=Panel1;
          Slable[i].caption:='第'+inttostr(i)+'个';
          Slable[i].top:=i*50+10;
          Slable[i].left:=i*50+10;
        end;
    end;
      

  2.   

    var
      Slable:array[1..10] of Tlable;
      ll:Table;
      i:=integer;
    begin
      for i:=1 to 10 do
        begin
          ll:=Slable.create(self);
          ll.parent:=Panel1;
          ll.caption:='第'+inttostr(i)+'个';
          ll.top:=i*50+10;
          ll.left:=i*50+10;
          Slable[i]:=ll;
        end;
    end;
      

  3.   

    一楼代码有误.. Slable[i]:=Slable.create(self);
    改..
          Slable[i]:=tlabel.create(self);二楼代码是垃圾..