给你一段代码(不好意思,BCB的)
class TForm1 :public TForm
{
...TEdit * pEdit[10];
}void __fastcall TForm1::FormCreate()
{
for (int i = 0; i < 10; i++)
{
    pEdit[i] = new TEdit(this);
    pEdit[i]->Parent = this;
    pEdit[i]->Top = i *40 + 5;
    pEdit[i]->Left = 20;
    pEdit[i]->Width = 100;
    pEdit[i]->Height = 20;
    ...
}
}

解决方案 »

  1.   

    没有
    var
    but:Tbutton;
    begin
    but:=Tbutton.create(self);
    but.caption:='...';
    but.left:=120;
    ..
    but.onclick:=someTnotifyevent;
    end;
      

  2.   

    var
      btn:array[1..10] of TButton;
    procedure TForm1.FormCreate(Sender:TObject);
    var
      i:integer;
    begin
      btn[1]:=Button1;
      btn[2]:=Button2;
      btn[3]:=Button3;
      btn[4]:=Button4;
      btn[5]:=Button5;
      btn[6]:=Button6;
      btn[7]:=Button7;
      btn[8]:=Button8;
      btn[9]:=Button9;
      btn[10]:=Button10;
      //定义事件
      for i:=0 to 10 do
        Btn[i].OnClick=BtnClick;//自己编写一个事件
    end;
    procedure TForm1.BtnClick(Sender:TObject);
    begin
      //首先要将Button1到Button10的Tag对应设置为1到10
      //根据tag进行对应处理
      case  TButton(Sender).tag  of
      1: ;
      2: ;
      3: ;
      4: ;
      5: ;
      6: ;
      7: ;
      8: ;
      9: ;
      10: ;
      end;
    end;
    试一试,怎么样?不明白再说!
      

  3.   

    也给你一个例子参考吧!8.1.1运行时生成控件
    ㈠、运行时生成可视控件:以下以TEdit 控件为例1.在Form的Public中定义TEdit控件Edit1:TEdit;2.在需要生成的地方加入以下代码:
    Edit1:=TEdit.Create(Self);
    Edit1.Parent:=Form1;
    Edit1.Left ?:=20;
    Edit1.Top :=20;
    Edit1.Text :='Edit1 Text';
    3.使用完毕后,释放分配的资源
    if? Assigned(Edit1) then Edit1.Free; ?
      

  4.   

    其实Delphi里有不下5种的解决方法,因为Component都为对象,其内存分配都在全局堆上进行,而不是在栈中,所以简单的方法就是用一个Tlist维护你的动态生成的Componnet, 用完再释放,例如:
    var
      fList : TList  function CreateObj(aOwner: TComppentn) : TComponent;
      begin
        Result := TSpeedButton.Create(aOwner);
        Result.Parnet := ..;
        ...
      End;  porcedure CreateButtonArray(aOwner : TComponent);
      var 
        i : integer;
      begin
        for i := 0 to 100 do
        fList.Add(CreateObj(aOwner));
      End;
      
      procedure FreeObj;
      var
        i : integer;
      begin
        if fList <> nil then
        for i := 0 to fList.Count do
          TSpeedButton(fList[i]).free;
      End;
     
       ...... initialization
       fList := TList.Create;
     finalization
       FreeObj;End.
      

  5.   

    var
      Btn:TButton;
    begin
      Btn:=TButton.Create(Self);  //创建一个组件
      Btn.Parent:=self;   //组件在主窗体上
      Btn.Left:=...
      Btn.Top:=...
      Btn.OnClick:=aProcedure  //映射Btn的单击事件
    end;