From Xojo Documentation

Class (inherits from Object)

Used to create a toolbar in a window. The Toolbar control is supported on all desktop platforms.

Action DropDownMenuAction
Close Open
Enabled Name TrueWindow fa-lock-32.png
Handle fa-lock-32.png Parent Visible
Height Top Width
Left Transparent Window fa-lock-32.png
AcceptFileDrop Close Item
AcceptPictureDrop Count Refresh
AcceptRawDataDrop DrawInto RefreshRect
AcceptTextDrop Insert Remove
Append Invalidate SetFocus


A Toolbar object contains all the buttons in a toolbar. You create the items in the toolbar with the ToolButton class and add them to the toolbar with the Append or Insert methods. An item can be either a button or a divider. A button can work as either a pushbutton or a toggle button.

For best results, you should ensure that all your toolbar icons are the same size. Some platforms will size all icons to that of the icon on the first button in the toolbar.
You can only have a single toolbar on a Window.

Mouse events

Although Toolbar inherits from RectControl, it has no mouse-related events. This is due to limitations of the operating system.

Sample Code

This example shows how to create a Toolbar via code. It builds a small Toolbar with Open and Save buttons. A Toolbar object was added to a window. The pictures that are displayed by the two buttons were added to the project.

The window has the following properties:

SaveButton As ToolButton
OpenButton As ToolButton

The following code is in the Open event of the Toolbar instance in the window.

SaveButton = New ToolButton
OpenButton = New ToolButton

SaveButton.Caption = "Save" // Caption appears below the Icon
SaveButton.Name = "Save"
SaveButton.icon = SaveButtonImage // image added to the project

OpenButton.Caption = "Open" // Caption appears below the Icon
OpenButton.Name = "Open"
OpenButton.icon = OpenButtonImage // image added to the project
SaveButton.Style = ToolButton.ToolStylePushButton
OpenButton.Style = ToolButton.ToolStylePushButton

// add to the Toolbar

The following code is in the Action event of the Toolbar in the window:

Sub Action(Item As ToolItem)
Select Case Item.Name
Case "Open"
MsgBox("You clicked the Open Button.")
Case "Save"
MsgBox("You clicked the Save Button.")
End Select
End Sub

See Also

ToolButton, ToolItem classes.