System.Windows.Forms.ToolBarButton Class

Represents a Windows toolbar button. Although System.Windows.Forms.ToolStripButton replaces and extends the System.Windows.Forms.ToolBarButton control of previous versions, System.Windows.Forms.ToolBarButton is retained for both backward compatibility and future use if you choose.

See Also: ToolBarButton Members


[System.ComponentModel.Designer("System.Windows.Forms.Design.ToolBarButtonDesigner, System.Design, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner")]
public class ToolBarButton : System.ComponentModel.Component


System.Windows.Forms.ToolBarButton controls are parented by System.Windows.Forms.ToolBar controls. Common properties to set once the toolbar button has been created are ToolBarButton.Text and ToolBarButton.ImageIndex. Set the ToolBarButton.Text property of the button to display text beneath or to the right of the image. To assign images to the buttons by creating an System.Windows.Forms.ImageList, assigning it to the ToolBar.ImageList property of the toolbar; then assign the image index value to the ToolBarButton.ImageIndex property of the button.

To change the appearance of the toolbar buttons assigned to the toolbar, set the ToolBar.Appearance property of the parent toolbar control. The ToolBarAppearance.Flat appearance gives the buttons a flat appearance. As the mouse pointer moves over the buttons, their appearance changes to three-dimensional. Button separators appear as lines rather than spaces between the buttons when the buttons have a flat appearance. If the ToolBar.Appearance property is set to ToolBarAppearance.Normal, the buttons appear raised and three-dimensional, and the separators appear as a gap between the buttons.

You can assign a System.Windows.Forms.ContextMenu to a button if the ToolBarButton.Style property is set to ToolBarButtonStyle.DropDown. When the button is clicked, the assigned menu is displayed.

To create a collection of System.Windows.Forms.ToolBarButton controls to display on a System.Windows.Forms.ToolBar, add the buttons individually by using the System.Windows.Forms.ToolBar.ToolBarButtonCollection.Add(ToolBarButton) method of the ToolBar.Buttons property. Alternatively, you can add several toolbar buttons using the System.Windows.Forms.ToolBar.ToolBarButtonCollection.AddRange(ToolBarButton[]) method.


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