for i:= 0 to count-1 do  
begin  
  BtnArray[i]:=TBuuton.Create(YourForm);
  BtnArray[i].Parent:=YourForm;  
  ......
end;在类里写个 procedure MyBtnClick(sender:TObject)
BtnArray[i].OnClick:=MyBtnClick;

解决方案 »

  1.   

    补充:
    var
      BtnArray : array[1..10] of TButton; 
    ……
      

  2.   

    以下代码是根据条件,取数据库记录生成SPEEDBUTTON。希望对你有帮助。
    var
      MyB:array of TSpeedButton;
    begin
        Setlength(MyB,table1.RecordCount);
        table1.First;
        i:=0;
        while not(table1.eof) do
        begin
          if table1.FieldByName('parent').asinteger=0 then
          begin
          MyB[I]:=TSpeedButton.Create(self);
          MyB[I].Parent:=panel1;
          {加入位置及宽高控制如:myb[i].width:=40;}
          MyB[i].flat:=true;
          MyB[i].caption:=trim(table1.fieldbyname('caption').asstring
          Myb[i].onClick:=buttonclick;//按纽事件
          i:=i+1;
          end;
          table1.next;
        end;
    end;
      

  3.   

    把INTEGER,TSTRING,TBUTTON...看成一样,只不过要先CREATE ,最后在FREE