System.Windows.Forms.ToolBar Class

Represents a Windows toolbar. Although System.Windows.Forms.ToolStrip replaces and adds functionality to the System.Windows.Forms.ToolBar control of previous versions, System.Windows.Forms.ToolBar is retained for both backward compatibility and future use if you choose.

See Also: ToolBar Members


[System.ComponentModel.Designer("System.Windows.Forms.Design.ToolBarDesigner, System.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
public class ToolBar : Control


System.Windows.Forms.ToolBar controls are used to display System.Windows.Forms.ToolBarButton controls that can appear as a standard button, a toggle-style button, or a drop-down style button. You can assign images to the buttons by creating an System.Windows.Forms.ImageList, assigning it to the ToolBar.ImageList property of the toolbar, and assigning the image index value to the ToolBarButton.ImageIndex property each System.Windows.Forms.ToolBarButton. You can then assign text to be displayed underneath or to the right of the image by setting the ToolBarButton.Text property of the System.Windows.Forms.ToolBarButton.

Set the ToolBar.Appearance property of the toolbar to ToolBarAppearance.Flat to give the toolbar and its buttons a flat appearance. As the mouse pointer moves over the buttons, their appearance changes to three-dimensional. Toolbar buttons can be divided into logical groups by using separators. A separator is a toolbar button with the ToolBarButton.Style property set to ToolBarButtonStyle.Separator. Button separators appear as lines rather than spaces between the buttons when the toolbar has a flat appearance. If the ToolBar.Appearance property is set to ToolBarAppearance.Normal, the toolbar buttons appear raised and three-dimensional.

If you specify a value for the ToolBar.ButtonSize property, all buttons in the tool bar are restricted to the specified size. Otherwise, the buttons adjust their size depending on their content, and the ToolBar.ButtonSize property returns the initial size of the largest button.

To create a collection of System.Windows.Forms.ToolBarButton controls to display on the System.Windows.Forms.ToolBar, add the buttons individually by using the System.Windows.Forms.ToolBar.ToolBarButtonCollection.Add(ToolBarButton) or System.Windows.Forms.ToolBar.ToolBarButtonCollection.Insert(int, ToolBarButton) methods of the ToolBar.Buttons property.


Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0,