怎样动态创建一些checkBox 控件,并显示在窗体上指定的位置

解决方案 »

  1.   

    var
      cb: TCheckBox;
    begin
      cb:=TCheckBox.Create(self);
      cb.parent:=panel1;
      cb.Left:=100;
      cb.Top:=100;
      cb.Caption:='Well';
      //......
    end;
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;
      i:integer=1;
      ileft:integer=0;
      itop:integer=0;
    implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    var checkbox:TCheckBox;
    begin
      checkbox:=TCheckBox.Create(Self);
      checkbox.Name:='CheckBox'+IntToStr(i);
      checkbox.Left:=ileft;
      checkbox.Top:=itop;
      checkbox.Parent:=Self;
      Inc(i);
      ileft:=ileft+10;
      itop:=itop+10;
    end;end.
      

  3.   

    var i:integer;
    begin
      for i:=0 to 9 do
      checklistbox1.Items.Add(inttostr(i));
    end;
      

  4.   

    additional页面下默认第10个控件
      

  5.   

    var cbx:TCheckBox;
    begin
      cbx:=TCheckBox.Create(Self);
      cbx.Parent:=Form1;
      cbx.Left:=1;
      cbx.Top:=1;
      cbx.Caption:='EveryThing';