Create TToolbutton runtime

后端 未结 3 387
一整个雨季
一整个雨季 2021-01-04 13:53

I have a problem with creating TToolbuttons at runtime and how they appear in my TToolbar.

Basically I got a toolbar with some buttons in i

3条回答
  •  说谎
    说谎 (楼主)
    2021-01-04 14:34

    You can use the left property of the TToolButton component

    check this sample

    //adding buttons to the end  of the ToolBar.
    procedure TForm1.Button1Click(Sender: TObject);
    var
     Toolbutton : TToolButton;
    begin
       Toolbutton :=TToolButton.Create(ToolBar1);
       Toolbutton.Parent  := ToolBar1;
       Toolbutton.Caption := IntToStr(ToolBar1.ButtonCount);
       Toolbutton.Left    := ToolBar1.Buttons[ToolBar1.ButtonCount-1].Left + ToolBar1.ButtonWidth;
    end;
    

提交回复
热议问题