ToolBarButtonClickEventArgsとは? わかりやすく解説

ToolBarButtonClickEventArgs クラス

ButtonClick イベントデータ提供します

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Class ToolBarButtonClickEventArgs
    Inherits EventArgs
Dim instance As ToolBarButtonClickEventArgs
public class ToolBarButtonClickEventArgs :
 EventArgs
public ref class ToolBarButtonClickEventArgs
 : public EventArgs
public class ToolBarButtonClickEventArgs extends
 EventArgs
public class ToolBarButtonClickEventArgs extends
 EventArgs
解説解説
使用例使用例

ToolBar3 つの ToolBarButton コントロールインスタンス化する例を次に示しますツール バー ボタンボタン コレクション割り当てられコレクションツール バー割り当てられツール バーフォーム追加されます。ツール バーButtonClick イベント発生すると、ToolBarButtonClickEventArgsButton プロパティ評価され適切なダイアログ開きます。このコードは、Form、OpenFileDialog、SaveFileDialog、および PrintDialog がすべてインスタンス化されていることを前提にしています。

Public Sub InitializeMyToolBar()
    ' Create and initialize the ToolBar and ToolBarButton controls.
    Dim toolBar1 As New
 ToolBar()
    Dim toolBarButton1 As New
 ToolBarButton()
    Dim toolBarButton2 As New
 ToolBarButton()
    Dim toolBarButton3 As New
 ToolBarButton()
    
    ' Set the Text properties of the ToolBarButton controls.
    toolBarButton1.Text = "Open"
    toolBarButton2.Text = "Save"
    toolBarButton3.Text = "Print"
    
    ' Add the ToolBarButton controls to the ToolBar.
    toolBar1.Buttons.Add(toolBarButton1)
    toolBar1.Buttons.Add(toolBarButton2)
    toolBar1.Buttons.Add(toolBarButton3)
    
    ' Add the event-handler delegate.
    AddHandler toolBar1.ButtonClick, AddressOf
 Me.toolBar1_ButtonClick
    
    ' Add the ToolBar to the Form.
    Controls.Add(toolBar1)
End Sub    

Private Sub toolBar1_ButtonClick(ByVal
 sender As Object, _
ByVal e As ToolBarButtonClickEventArgs)

    ' Evaluate the Button property to determine which button was clicked.
    Select Case toolBar1.Buttons.IndexOf(e.Button)
        Case 0
            openFileDialog1.ShowDialog()
            ' Insert code to open the file.
        Case 1
            saveFileDialog1.ShowDialog()
            ' Insert code to save the file.
        Case 2
            printDialog1.ShowDialog()
            ' Insert code to print the file.
    End Select
End Sub

public void InitializeMyToolBar()
 {
    // Create and initialize the ToolBar and ToolBarButton controls.
    toolBar1 = new ToolBar();
    ToolBarButton toolBarButton1 = new ToolBarButton();
    ToolBarButton toolBarButton2 = new ToolBarButton();
    ToolBarButton toolBarButton3 = new ToolBarButton();
 
    // Set the Text properties of the ToolBarButton controls.
    toolBarButton1.Text = "Open";
    toolBarButton2.Text = "Save";
    toolBarButton3.Text = "Print";
 
    // Add the ToolBarButton controls to the ToolBar.
    toolBar1.Buttons.Add(toolBarButton1);
    toolBar1.Buttons.Add(toolBarButton2);
    toolBar1.Buttons.Add(toolBarButton3);
    
    // Add the event-handler delegate.
    toolBar1.ButtonClick += new ToolBarButtonClickEventHandler
 (
       this.toolBar1_ButtonClick);
    
    // Add the ToolBar to the Form.
    Controls.Add(toolBar1);
 }
 
 private void toolBar1_ButtonClick (
                         Object sender, 
                         ToolBarButtonClickEventArgs e)
 {
   // Evaluate the Button property to determine which button was clicked.
   switch(toolBar1.Buttons.IndexOf(e.Button))
   {
      case 0:
         openFileDialog1.ShowDialog();
         // Insert code to open the file.
         break; 
      case 1:
         saveFileDialog1.ShowDialog();
         // Insert code to save the file.
         break; 
      case 2:
         printDialog1.ShowDialog();
         // Insert code to print the file.    
         break; 
    }
 }

public:
   void InitializeMyToolBar()
   {
      // Create and initialize the ToolBar and ToolBarButton controls.
      toolBar1 = gcnew ToolBar;
      ToolBarButton^ toolBarButton1 = gcnew ToolBarButton;
      ToolBarButton^ toolBarButton2 = gcnew ToolBarButton;
      ToolBarButton^ toolBarButton3 = gcnew ToolBarButton;
      
      // Set the Text properties of the ToolBarButton controls.
      toolBarButton1->Text = "Open";
      toolBarButton2->Text = "Save";
      toolBarButton3->Text = "Print";
      
      // Add the ToolBarButton controls to the ToolBar.
      toolBar1->Buttons->Add( toolBarButton1 );
      toolBar1->Buttons->Add( toolBarButton2 );
      toolBar1->Buttons->Add( toolBarButton3 );
      
      // Add the event-handler delegate.
      toolBar1->ButtonClick += gcnew ToolBarButtonClickEventHandler(
         this, &Form1::toolBar1_ButtonClick );
      
      // Add the ToolBar to the Form.
      Controls->Add( toolBar1 );
   }

private:
   void toolBar1_ButtonClick(
      Object^ sender,
      ToolBarButtonClickEventArgs^ e )
   {
      // Evaluate the Button property to determine which button was
 clicked.
      switch ( toolBar1->Buttons->IndexOf( e->Button
 ) )
      {
         case 0:
            openFileDialog1->ShowDialog();
            // Insert code to open the file.
            break;
         case 1:
            saveFileDialog1->ShowDialog();
            // Insert code to save the file.
            break;
         case 2:
            printDialog1->ShowDialog();
            // Insert code to print the file.    
            break;
      }
   }
public void InitializeMyToolBar()
{
    // Create and initialize the ToolBar and ToolBarButton controls.
    toolBar1 = new ToolBar();
    ToolBarButton toolBarButton1 = new ToolBarButton();
    ToolBarButton toolBarButton2 = new ToolBarButton();
    ToolBarButton toolBarButton3 = new ToolBarButton();

    // Set the Text properties of the ToolBarButton controls.
    toolBarButton1.set_Text("Open");
    toolBarButton2.set_Text("Save");
    toolBarButton3.set_Text("Print");

    // Add the ToolBarButton controls to the ToolBar.
    toolBar1.get_Buttons().Add(toolBarButton1);
    toolBar1.get_Buttons().Add(toolBarButton2);
    toolBar1.get_Buttons().Add(toolBarButton3);

    // Add the event-handler delegate.
    toolBar1.add_ButtonClick(new ToolBarButtonClickEventHandler(
                                 this.toolBar1_ButtonClick));

    // Add the ToolBar to the Form.
    get_Controls().Add(toolBar1);
} //InitializeMyToolBar

protected void toolBar1_ButtonClick(Object
 sender,
                                    ToolBarButtonClickEventArgs e)
{
    // Evaluate the Button property to determine which button was clicked.
    switch (toolBar1.get_Buttons().IndexOf(e.get_Button())) {
        case 0 :
            openFileDialog1.ShowDialog();
            // Insert code to open the file.
            break;
        case 1 :
            saveFileDialog1.ShowDialog();
            // Insert code to save the file.
            break;
        case 2 :
            printDialog1.ShowDialog();
            // Insert code to print the file.    
            break;
    } 
} //toolBar1_ButtonClick
継承階層継承階層
System.Object
   System.EventArgs
    System.Windows.Forms.ToolBarButtonClickEventArgs
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

ToolBarButtonClickEventArgs コンストラクタ

ToolBarButtonClickEventArgs クラス新しインスタンス初期化します。

名前空間: System.Windows.Forms
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)
構文構文

Public Sub New ( _
    button As ToolBarButton _
)
Dim button As ToolBarButton

Dim instance As New ToolBarButtonClickEventArgs(button)
public ToolBarButtonClickEventArgs (
    ToolBarButton button
)
public:
ToolBarButtonClickEventArgs (
    ToolBarButton^ button
)
public ToolBarButtonClickEventArgs (
    ToolBarButton button
)
public function ToolBarButtonClickEventArgs
 (
    button : ToolBarButton
)

パラメータ

button

クリックされた ToolBarButton。

解説解説
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ToolBarButtonClickEventArgs クラス
ToolBarButtonClickEventArgs メンバ
System.Windows.Forms 名前空間
ToolBarButton クラス

ToolBarButtonClickEventArgs プロパティ


パブリック プロパティパブリック プロパティ

  名前 説明
パブリック プロパティ Button クリックされた ToolBarButton を取得または設定します
参照参照

関連項目

ToolBarButtonClickEventArgs クラス
System.Windows.Forms 名前空間
ToolBar クラス
ToolBarButton クラス

ToolBarButtonClickEventArgs メソッド


ToolBarButtonClickEventArgs メンバ

ButtonClick イベントデータ提供します

ToolBarButtonClickEventArgs データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
  名前 説明
パブリック メソッド ToolBarButtonClickEventArgs ToolBarButtonClickEventArgs クラス新しインスタンス初期化します。
パブリック プロパティパブリック プロパティ
  名前 説明
パブリック プロパティ Button クリックされた ToolBarButton を取得または設定します
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

ToolBarButtonClickEventArgs クラス
System.Windows.Forms 名前空間
ToolBar クラス
ToolBarButton クラス



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ToolBarButtonClickEventArgs」の関連用語

ToolBarButtonClickEventArgsのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ToolBarButtonClickEventArgsのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS