ToolBarButtonStyle 枚举

定义

指定工具栏中按钮的样式。Specifies the button style within a toolbar.

public enum class ToolBarButtonStyle
public enum ToolBarButtonStyle
type ToolBarButtonStyle = 
Public Enum ToolBarButtonStyle
继承
ToolBarButtonStyle

字段

DropDownButton 4

单击时显示菜单或其他窗口的下拉控件。A drop-down control that displays a menu or other window when clicked.

PushButton 1

标准的三维按钮。A standard, three-dimensional button.

Separator 3

工具栏按钮之间的间隔或线。A space or line between toolbar buttons. 外观取决于 Appearance 属性的值。The appearance depends on the value of the Appearance property.

ToggleButton 2

一个切换按钮,在单击时外观变为凹下,并将凹下外观一直保持到再次单击时。A toggle button that appears sunken when clicked and retains the sunken appearance until clicked again.

示例

下面的示例实例化ToolBar一个和ToolBarButton三个控件, 将按钮赋给工具栏, 并设置一些按钮的通用属性。The following example instantiates a ToolBar and three ToolBarButton controls, assigns the buttons to the toolbar, and sets some of the buttons' common properties. 此代码假定已经MenuItem实例ImageListToolTip了、 Form和, 并且ImageList至少分配有一个ImageThis 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 = gcnew ToolBarButton( "Open" );
      ToolBarButton^ toolBarButton2 = gcnew ToolBarButton;
      ToolBarButton^ toolBarButton3 = gcnew ToolBarButton;
      ToolBar^ toolBar1 = gcnew ToolBar;
      MenuItem^ menuItem1 = gcnew MenuItem( "Print" );
      array<MenuItem^>^ temp1 = {menuItem1};
      System::Windows::Forms::ContextMenu^ contextMenu1 =
         gcnew 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 = "Print";
      toolBarButton3->Style = ToolBarButtonStyle::DropDownButton;
      toolBarButton3->ToolTipText = "Print";
      toolBarButton3->ImageIndex = 0;
      toolBarButton3->DropDownMenu = contextMenu1;
      
      // Add the ToolBar to a form.
      Controls->Add( toolBar1 );
   }
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);
 }
 
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

注解

此枚举由成员 (如) ToolBarButton.Style使用。This enumeration is used by members such as ToolBarButton.Style.

工具栏按钮外观由工具栏的Appearance属性确定。The toolbar button appearance is determined by the Appearance property of the toolbar. 将属性设置为Flat将使工具栏及其按钮为平面外观。 AppearanceSetting 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.

适用于

另请参阅