ToolBarButton.Style プロパティ
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As ToolBarButton Dim value As ToolBarButtonStyle value = instance.Style instance.Style = value
public: property ToolBarButtonStyle Style { ToolBarButtonStyle get (); void set (ToolBarButtonStyle value); }
/** @property */ public ToolBarButtonStyle get_Style () /** @property */ public void set_Style (ToolBarButtonStyle value)
public function get Style () : ToolBarButtonStyle public function set Style (value : ToolBarButtonStyle)
ToolBarButtonStyle 値の 1 つ。既定値は ToolBarButtonStyle.PushButton です。


ボタンの Style が DropDownButton に設定されている場合は、ドロップダウン ボタンを押すと MenuItem が表示されるように指定できます。スタイルが ToolBarButtonStyle.Separator に設定されているツール バー ボタンは、ボタンではなく、ボタンの区切り記号として表示されます。ToolBarButtonStyle.ToggleButton スタイルを指定すると、ツール バー ボタンはトグル ボタンのように機能し、オンとオフの状態を切り替えることができます。

ToolBar と 3 つの ToolBarButton コントロールを作成し、ボタンをツール バーに割り当ててから、ボタンの共通プロパティの一部を設定するコード例を次に示します。このコードは、MenuItem、ImageList、ToolTip、および Form が作成されていることと、ImageList に少なくとも 1 つの Image が割り当てられていることを前提にしています。
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
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: 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.get_Buttons().Add(toolBarButton1); toolBar1.get_Buttons().Add(toolBarButton2); toolBar1.get_Buttons().Add(toolBarButton3); // Assign an ImageList to the ToolBar and show ToolTips. toolBar1.set_ImageList(imageList1); toolBar1.set_ShowToolTips(true); /* Assign ImageIndex, ContextMenu, Text, ToolTip, and * Style properties of the ToolBarButton controls. */ toolBarButton2.set_Style(ToolBarButtonStyle.Separator); toolBarButton3.set_Text("Print"); toolBarButton3.set_Style(ToolBarButtonStyle.DropDownButton); toolBarButton3.set_ToolTipText("Print"); toolBarButton3.set_ImageIndex(0); toolBarButton3.set_DropDownMenu(contextMenu1); // Add the ToolBar to a form. get_Controls().Add(toolBar1); } //InitializeMyToolBar

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


ToolBarButtonStyle 列挙体
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Public Enumeration ToolBarButtonStyle

メンバ名 | 説明 | |
---|---|---|
![]() | DropDownButton | クリックされたときに、メニューまたは他のウィンドウを表示するドロップダウン コントロール。 |
![]() | PushButton | 標準の 3D ボタン。 |
![]() | Separator | ツール バー ボタンの間の空白または線。外観は、Appearance プロパティの値によって異なります。 |
![]() | ToggleButton | トグル ボタンは、クリックされるとくぼんだ状態で表示され、もう一度クリックすると、元に戻ります。 |

この列挙体は、ToolBarButton.Style などのメンバで使用されます。
ツール バー ボタンの外観は、ツール バーの Appearance プロパティで決定されます。Appearance プロパティを Flat に設定すると、ツール バーとそのボタンはフラットな外観になります。マウス ポインタがボタンの上に移動すると、ボタンの外観は 3D に変わります。また、ツール バーがフラットな外観である場合、ボタンの区切り記号は、各ボタンとの間に空白ではなく線として表示されます。

ToolBar と 3 つの ToolBarButton コントロールをインスタンス化し、ボタンをツール バーに割り当ててから、ボタンの共通プロパティの一部を設定する例を次に示します。このコードは、MenuItem、ImageList、ToolTip、および Form がインスタンス化されていることと、ImageList に少なくとも 1 つの Image が割り当てられていることを前提にしています。
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
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: 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.get_Buttons().Add(toolBarButton1); toolBar1.get_Buttons().Add(toolBarButton2); toolBar1.get_Buttons().Add(toolBarButton3); // Assign an ImageList to the ToolBar and show ToolTips. toolBar1.set_ImageList(imageList1); toolBar1.set_ShowToolTips(true); /* Assign ImageIndex, ContextMenu, Text, ToolTip, and * Style properties of the ToolBarButton controls. */ toolBarButton2.set_Style(ToolBarButtonStyle.Separator); toolBarButton3.set_Text("Print"); toolBarButton3.set_Style(ToolBarButtonStyle.DropDownButton); toolBarButton3.set_ToolTipText("Print"); toolBarButton3.set_ImageIndex(0); toolBarButton3.set_DropDownMenu(contextMenu1); // Add the ToolBar to a form. get_Controls().Add(toolBar1); } //InitializeMyToolBar

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- ToolBarButtonStyleのページへのリンク