This documentation is archived and is not being maintained.

ToolBarButtonStyle Enumeration

Specifies the button style within a toolbar.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public enum ToolBarButtonStyle

Member nameDescription
Supported by the .NET Compact FrameworkPushButtonA standard, three-dimensional button.
Supported by the .NET Compact FrameworkToggleButtonA toggle button that appears sunken when clicked and retains the sunken appearance until clicked again.
Supported by the .NET Compact FrameworkSeparatorA space or line between toolbar buttons. The appearance depends on the value of the Appearance property.
Supported by the .NET Compact FrameworkDropDownButtonA drop-down control that displays a menu or other window when clicked.

This enumeration is used by members such as ToolBarButton.Style.

The toolbar button appearance is determined by the Appearance property of the toolbar. Setting the Appearance property to Flat will give the toolbar and its buttons a flat appearance. As the mouse pointer moves over the buttons, they take on a three-dimensional appearance. Also, when the toolbar has a flat appearance, button separators appear as a line rather than as a space between the buttons.

The following example instantiates a ToolBar and three ToolBarButton controls, assigns the buttons to the toolbar, and sets some of the buttons' common properties. This code assumes a MenuItem, ImageList, ToolTip and a Form have been instantiated and the ImageList has at least one Image assigned to it.

public void InitializeMyToolBar()
    // Create the ToolBar, ToolBarButton controls, and menus.
    ToolBarButton toolBarButton1 = new ToolBarButton("Open");
    ToolBarButton toolBarButton2 = new ToolBarButton();
    ToolBarButton toolBarButton3 = new ToolBarButton();
    ToolBar toolBar1 = new ToolBar();
    MenuItem menuItem1 = new MenuItem("Print");
    ContextMenu contextMenu1 = new ContextMenu(new MenuItem[]{menuItem1});

    // Add the ToolBarButton controls to the ToolBar.

    // Assign an ImageList to the ToolBar and show ToolTips.
    toolBar1.ImageList = imageList1;
    toolBar1.ShowToolTips = true;

    /* Assign ImageIndex, ContextMenu, Text, ToolTip, and 
       Style properties of the ToolBarButton controls. */
    toolBarButton2.Style = ToolBarButtonStyle.Separator;
    toolBarButton3.Text = "Print";
    toolBarButton3.Style = ToolBarButtonStyle.DropDownButton;
    toolBarButton3.ToolTipText = "Print";
    toolBarButton3.ImageIndex = 0;
    toolBarButton3.DropDownMenu = contextMenu1;

    // Add the ToolBar to a form.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0