如何在Toolbar中动态添加Toolbutton

解决方案 »

  1.   

    var
      tb:TToolButton;
    begin
      tb:=TToolButton.Create(toolbar1);
      tb.Parent:=toolbar1;
    end;
      

  2.   

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      ToolBar1.ShowCaptions := True;
      ToolBar1.Tag := 5;end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      if ToolBar1.Tag = 0 then
        Exit;
      with TToolButton.Create(ToolBar1) do
      begin
        Caption := 'Button' + IntToStr(ToolBar1.Tag);
        Style := tbsTextButton;
        Parent := ToolBar1;
      end;
      ToolBar1.Tag := ToolBar1.Tag - 1;
    end;
      

  3.   

    怪了...上方二樓(#2)不見了是怎麼回是呢?這是我來 Delphi 板回覆帖子...第二次發生回覆信息莫名消失...... 已向 csdn 通報!