ToolBarButtonStyle ToolBarButtonStyle ToolBarButtonStyle ToolBarButtonStyle Enum

定义

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

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

字段

DropDownButton DropDownButton DropDownButton DropDownButton 4

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

PushButton PushButton PushButton PushButton 1

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

Separator Separator Separator Separator 3

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

ToggleButton ToggleButton ToggleButton 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. 此代码假定MenuItemImageListToolTip和一个Form已实例化并ImageList至少有一个Image分配给它。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 = 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.StyleThis enumeration is used by members such as ToolBarButton.Style.

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

适用于

另请参阅