mdir,mconn,csql:string;
tb:array [1..30] of ttoolbutton;
procedure TForm1.FormShow(Sender: TObject);
var
  i:integer;
  theIcon:TICON;
begin
  mdir:=GetCurrentDir();
  mconn:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+mdir+'\source.mdb;Persist Security Info=False';
  csql:='select xmmc,ico from xmbmk order by xm_id';
  xmQuery.Close();
  xmQuery.ConnectionString:=mconn;
  xmQuery.SQL.Clear();
  xmQuery.SQL.Add(csql);
  xmQuery.Open;
  xmQuery.first;  ImageList1.Clear;
  if xmQuery.RecordCount>0 then
  for i:=1 to xmQuery.RecordCount do
  begin
    tb[i]:=TToolButton.Create(self);
    tb[i].AutoSize:=true;
    tb[i].Grouped:=true;
    tb[i].Style:=tbscheck;
    tb[i].Caption:=trim(xmQuery.fieldbyname('xmmc').AsString);    theIcon:=TICON.Create;
    theIcon.LoadFromFile(trim(xmQuery.fieldbyname('ico').AsString));
    ImageList1.Addicon(theIcon);    tb[i].ImageIndex:=i-1;
    xmQuery.Next();
  end;
end;
我是想把按钮 tb[i]创建到控件toolbar上