你这样做不是很麻烦?
创建edit
myedit : Tedit ;
  myedit := Tedit.Create (self) ;
  myedit.Parent := form1 ;
  myedit.Top := 100 ;
  myedit.Left := 200 ;

解决方案 »

  1.   

    var
      Edit:TEdit;
    begin
      //把属性值存下来
      Edit:=TEdit.Create(self);
      Edit.Parent:=Self;
      Edit.Left:=x;
      Edit.Top:=y;
      Edit.Height:=...
      Edit.Width;=...
      Edit.OnClick:=MyClick;
      ....
      Edit.Show;end;procedure MyClick(Sender:TObject);
    begin
      //.....
    end;
    其它同上。
      

  2.   

    procedure TForm1.Button1Click(Sender: TObject);  //增加组件
    var i:integer;
        Edit:TEdit;
    begin    //以Tag为标准.
      for i:=0 to ListBox1.Items.Count-1 do
       begin
         Edit:=TEdit.Create(self);
         Edit.Name:='Edit'+ListBox1.Items.Strings[i];
         Edit.Parent:=self;
         Edit.Left:=i*60;
         Edit.Top:=i*5;
         Edit.Tag:=strtoint(ListBox1.Items.Strings[i]);
       end; 
    end;procedure TForm1.Button2Click(Sender: TObject); //查看组件数
    var i,n:integer;
        str,str1:string;
    begin
     n:=0;
     str:='';
     showmessage('组件数:'+inttostr(self.ComponentCount));
     for i:=0 to self.ComponentCount-1 do
      begin
        if self.Components[i].ClassName='TEdit' then
         begin
              n:=n+1;
              str:=str+' '+self.Components[i].Name;
              case self.Components[i].Tag of
              100:     begin ...你要对这个控件做的事..  end;
              111:     begin ...你要对这个控件做的事.. end;
                { ..........}
              end;
         end;
      end;
     showmessage('TEdit组件数:'+Inttostr(n));
     showmessage(str);
    end;
    { 此例已测试过. }
      

  3.   

    procedure TForm1.Button1Click(Sender: TObject);
    var SA:array[0..100] of TLabel;//数量自己定义
        SS:array[0..100] of TEdit;
    begin  SA[0]:=TLabel.Create(self);
      SA[0].Parent:=Form1;
      SA[0].Caption:='ok';
      SS[0]:=TEdit.Create(self);
      ss[0].Parent:=Form1;
      ss[0].Left:=200;end;
      

  4.   

    procedure TForm1.SpeedButton1Click(Sender: TObject);
    var
      edt:array of TEdit;
      lbl:array of Tlabel;
      i,iCount:integer;
    begin
      iCount:= table1.FieldCount;
      setlength(edt,iCount);
      setlength(lbl,iCount);
      for i:=0 to iCount-1 do
      begin    lbl[i]:=Tlabel.Create(self);
        lbl[i].Parent := form1;
        lbl[i].Left := 90;
        lbl[i].Top := i*30+50;
        lbl[i].Caption := table1.Fields[i].FieldName;    edt[i]:=TEdit.Create(self);
        edt[i].Parent := form1;
        edt[i].left := 200;
        edt[i].top:=i*30+50;
        edt[i].Text := '';
      end;
    end;
      

  5.   

        procedure setCtl();
        var lab : array of TLabel;
            edt : array of TEdit;
            arrCtlno : integer;
        begin
                arrCtlno := 10; //每种控件生成10个
                SetLength(lab, arrCtlno);
                SetLength(edt, arrCtlno);                lab[no] := TLabel.Create(self);
                    edt[no] := TEdit.Create(self);                lab[no].Parent := Form1;
                    lab[no].Top := 10;
                    lab[no].Left := 30;
                    lab[no].Width := 70;
                    lab[no].Font.Style := [fsBold];
                    lab[no].Caption := IntToStr(service_no);
                    lab[no].Visible := true;                edt[no].Parent := Form1;
                    edt[no].Text := 'xxxxxxxxxxxxx';
                    edt[no].Top := 5;
                    edt[no].Left := 100;
                    edt[no].Width := 100;
                    edt[no].Visible := true;
        end;
      

  6.   

        tt:=tlabel.Create(self); //创建LABEL
        comcount:=comcount+1;
        tt.Name:='compo'+inttostr(comcount);  //以compo+序号来命名控件
        tt.Top:=10+(j  mod 7)*(44+5);
        tt.Left:=30+((j mod 21) div 7)*220;
        tt.Caption:='compo'+inttostr(comcount);//创建DBEDIT
          dd:=tdbedit.Create(self);
          comcount:=comcount+1;
          dbcount:=dbcount+1;
          dd.Name:='compo'+inttostr(comcount);  //以compo+序号来命名控件
          dd.Width:=170;
          dd.DataSource:=dm1.datasource1;
      

  7.   

    var
      Edit:TEdit;
    begin
      Edit:=TEdit.Create(self);
      Edit.Parent:=Self;
      Edit.Left:=x;
      Edit.Top:=y;
      Edit.Height:=...
      Edit.Width;=...
      Edit.OnClick:=MyClick;
      ....
      Edit.Show;end;狂人也有这样的例子,不过觉得简单,但是易用。。
      

  8.   

    创建空件很容易,难的是怎么调用他,比如先付给生成的edit的焦点,然后,想获取edit的值。
      

  9.   

    这个很容易
    用form的方法
    findcomponent(名字)或 findchildcontrol(名字)
    都可以(必须还要类型转换)
    你在创建时把名字起好,
    比如是edit就起“E”+字段名
    label就起"l"+字段名
    我试验过没问题
      

  10.   

    首先将控件的INDEX设为0,然后在需要动态产生的时候写如下代码:
    LOAD LABEL(1)
    LABEL(1).LEFT=...
    LABEL(1).TOP=...
    LABEL(1).VISIBAL=TRUE
    不需要使用的时候,只需UNLOAD LABEL(1)
    注意只有在存在该控件的时候才能卸载,否则出错;
    另外,如果不卸载而再加载一次,出错;
      

  11.   

    VB6 可以实现此功能.
    给分提供源码>
      

  12.   

    假设已经动态生成了个button,怎么捕获他的动作事件????/
      

  13.   

    使用TList建立就好了:var EditList,LabList : TList;
        i : integer;
        Lab : TLable;
        Edt : TEdit;
    begin
      EditList := TList.Create;
      LabList := TList.Create;
      try
        for i := 0 to FieldCount-1 do 
        begin
          Lab := TLable.Create(self);
          Edt := TEdit.Create(self);
          Edt.Parent := form1 ;
          Edt.Top := 100 ;
          Edt.Left := 200 ;      Lab.Parent := form1 ;
          Lab.Top := 100 ;
          Lab.Left := 100 ;  
          EditList.Add(Edt);      
          LabList.Add(Lab);      
        end;    TEdit(EditList[0]).Text := 'Test';
     
      finally
        EditList := TList.Create;
        LabList := TList.Create;
      end;
    end; 
    使用指针应该没有问题;我经常这样做.
      

  14.   

    我自己搞定拉,谢谢大家!
    procedure TForm1.Button1Click(Sender: TObject);
    var
      Btn: TButton;
    begin
      Btn := TButton.Create (self);
      Btn.Parent := self;
      Btn.Left :=20;
      Btn.Top := 20;
      Btn.Width := Btn.Width + 50;
      Btn.Caption := Format ('Button at %d, %d', [10, 10]);
      btn.OnClick:=buttonclick;end;procedure TForm1.ButtonClick(Sender: TObject);
    beginshowmessage('笨蛋');
    end;end.