Export (0) Print
Expand All
Expand Minimize

ToolBarButtonStyle Enumeration

Specifies the button style within a toolbar.

[Visual Basic]
<Serializable>
Public Enum ToolBarButtonStyle
[C#]
[Serializable]
public enum ToolBarButtonStyle
[C++]
[Serializable]
__value public enum ToolBarButtonStyle
[JScript]
public
   Serializable
enum ToolBarButtonStyle

Remarks

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.

Members

Member name Description
DropDownButton

Supported by the .NET Compact Framework.

A drop-down control that displays a menu or other window when clicked.
PushButton

Supported by the .NET Compact Framework.

A standard, three-dimensional button.
Separator

Supported by the .NET Compact Framework.

A space or line between toolbar buttons. The appearance depends on the value of the Appearance property.
ToggleButton

Supported by the .NET Compact Framework.

A toggle button that appears sunken when clicked and retains the sunken appearance until clicked again.

Example

[Visual Basic, C#, C++] 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.

[Visual Basic] 
Public Sub InitializeMyToolBar()
    ' Create the ToolBar, ToolBarButton controls, and menus.
    Dim toolBarButton1 As New ToolBarButton("Open")
    Dim toolBarButton2 As New ToolBarButton()
    Dim toolBarButton3 As New ToolBarButton()
    Dim toolBar1 As New ToolBar()
Dim menuItem1 As New MenuItem("Print")
Dim contextMenu1 As New ContextMenu(New MenuItem(){menuItem1})
    
    ' Add the ToolBarButton controls to the ToolBar.
    toolBar1.Buttons.Add(toolBarButton1)
    toolBar1.Buttons.Add(toolBarButton2)
    toolBar1.Buttons.Add(toolBarButton3)
    
    ' 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.
    Controls.Add(toolBar1)
End Sub


[C#] 
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.
    toolBar1.Buttons.Add(toolBarButton1);
    toolBar1.Buttons.Add(toolBarButton2);
    toolBar1.Buttons.Add(toolBarButton3);
 
    // 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.
    Controls.Add(toolBar1);
 }
 

[C++] 
public:
void InitializeMyToolBar()
 {
    // Create the ToolBar, ToolBarButton controls, and menus.
    ToolBarButton* toolBarButton1 = new ToolBarButton(S"Open");
    ToolBarButton* toolBarButton2 = new ToolBarButton();
    ToolBarButton* toolBarButton3 = new ToolBarButton();
    ToolBar* toolBar1 = new ToolBar();
    MenuItem* menuItem1 = new MenuItem(S"Print");

    MenuItem* temp1 [] = {menuItem1};
    System::Windows::Forms::ContextMenu* contextMenu1 = new System::Windows::Forms::ContextMenu(temp1);

     
    // Add the ToolBarButton controls to the ToolBar.
    toolBar1->Buttons->Add(toolBarButton1);
    toolBar1->Buttons->Add(toolBarButton2);
    toolBar1->Buttons->Add(toolBarButton3);
 
    // 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 = S"Print";
    toolBarButton3->Style = ToolBarButtonStyle::DropDownButton;
    toolBarButton3->ToolTipText = S"Print";
    toolBarButton3->ImageIndex = 0;
    toolBarButton3->DropDownMenu = contextMenu1;
 
    // Add the ToolBar to a form.
    Controls->Add(toolBar1);
 }
 

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Windows.Forms

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

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

See Also

System.Windows.Forms Namespace | ToolBarAppearance | ToolBar

Show:
© 2014 Microsoft