var dis_pro :Array of TCheckBox;TempCount:=DS_Data.Qu_sbsys.RecordCount;
SetLength(dis_pro,TempCount);
Ds_Data.qu_sbsys.First;
for i:=0 to TempCount do
begin
  dis_Pro[i]:=TCheckBox1.Create(Self);
  Dis_Pro[i].Parent:=Self;
  Dis_Pro[i].Caption:=ds_data.Qu_sbsys.FieldByName('ch2').AsString;
  ds_data.Qu_sbsys.Next;
end;

解决方案 »

  1.   

    首先定义一个动态数组
    dis_pro: Array of TCheckBox;
    然后得到数据库返回值的个数。
    DB_count := 数据源返回的个数.
    接下来设置动态数组。
    SetLength(dis_pro, DB_count);
    for i:= 0 to DB_count - 1 do
      begin
        dis_pro[i] := TCheckBox.Create(Self);//创建它
        dis_pro[i].Parent := ...//设置它依属的容器
        dis_pro[i].SetBounds(..., ..., ..., ...);//设置边界
        dis_pro[i].Caption := ... ;
      end;
    这样可以了吗?^&^
      

  2.   

    对了,你如果想将数据库中的字段值送入CheckBox,你还得加上在Being...End;
    中加上
       disPro[i].(你要赋值的属性):= 你想要赋值的内容。
       数据源.Next;//是让它指向下一条记录.
      

  3.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls;type
      TForm1 = class(TForm)
        procedure FormCreate(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
    const c=50;
    var
    dis_pro : array[0..c] of TCheckBox;  //数组控件
    i:integer;
    begin
     for i:=1 to c do begin
      dis_pro[i]:=tcheckbox.create(self);
      with dis_pro[i] do begin
        parent:=form1;
        top:=i*20;
        caption:='tcheckbox'+inttostr(i);
        show;
      end;
     end;
    end;end.
      

  4.   

    for I := 0 to 10000 do
      TCheckBox(FindComponent('CheckBox' + IntToStr(I))).Caption := .......当然啦,创建时的名称也要遵循'CheckBox' + IntToStr(I)的规则了.
      

  5.   

      现在是这样的,我想动态创建一个容器,里面还有他自己的控件。
    比如这样:容器是GROUPBOX1,在里面有几个Label和Edit控件,假如是两个Label,和两个Edit控件并且要在GroupBox1中,自动排列整齐,那么这样的效果该如何实现。
      

  6.   

    适当设置Label和Edit控件的left,top属性值