ToolBar.ToolBarButtonCollection.Contains メソッドとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ToolBar.ToolBarButtonCollection.Contains メソッドの意味・解説 

ToolBar.ToolBarButtonCollection.Contains メソッド

指定したツール バー ボタンコレクションメンバかどうか確認します

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

Public Function Contains ( _
    button As ToolBarButton _
) As Boolean
Dim instance As ToolBarButtonCollection
Dim button As ToolBarButton
Dim returnValue As Boolean

returnValue = instance.Contains(button)
public bool Contains (
    ToolBarButton button
)
public:
bool Contains (
    ToolBarButton^ button
)
public boolean Contains (
    ToolBarButton button
)
public function Contains (
    button : ToolBarButton
) : boolean

パラメータ

button

コレクションで検索する ToolBarButton。

戻り値
ToolBarButtonコレクションメンバ場合trueそれ以外場合false

解説解説
使用例使用例

存在する場合ToolBar コントロールか既存ToolBarButton削除しToolBar新し4 つToolBarButton オブジェクト追加して挿入するコード例次に示します。この例では、ToolBar コントロール配置されForm存在している必要があります

Private Sub AddToolbarButtons(toolBar As
 ToolBar)
   If Not toolBar.Buttons.IsReadOnly Then
      ' If toolBarButton1 in in the collection, remove it.
      If toolBar.Buttons.Contains(toolBarButton1) Then
         toolBar.Buttons.Remove(toolBarButton1)
      End If

      ' Create three toolbar buttons.
      Dim tbb1 As New ToolBarButton("tbb1")
      Dim tbb2 As New ToolBarButton("tbb2")
      Dim tbb3 As New ToolBarButton("tbb3")

      ' Add toolbar buttons to the toolbar.        
      toolBar.Buttons.AddRange(New ToolBarButton() {tbb2, tbb3})
      toolBar.Buttons.Add("tbb4")

      ' Insert tbb1 into the first position in the collection.
      toolBar.Buttons.Insert(0, tbb1)
   End If
End Sub
private void AddToolbarButtons(ToolBar toolBar)
{
   if(!toolBar.Buttons.IsReadOnly)
   {
      // If toolBarButton1 in in the collection, remove it.
      if(toolBar.Buttons.Contains(toolBarButton1))
      {
         toolBar.Buttons.Remove(toolBarButton1);
      }
    
      // Create three toolbar buttons.
      ToolBarButton tbb1 = new ToolBarButton("tbb1");
      ToolBarButton tbb2 = new ToolBarButton("tbb2");
      ToolBarButton tbb3 = new ToolBarButton("tbb3");
      
      // Add toolbar buttons to the toolbar.        
      toolBar.Buttons.AddRange(new ToolBarButton[] {tbb2, tbb3});
      toolBar.Buttons.Add("tbb4");
    
      // Insert tbb1 into the first position in the collection.
      toolBar.Buttons.Insert(0, tbb1);
   }
}
void AddToolbarButtons( ToolBar^ toolBar )
{
   if (  !toolBar->Buttons->IsReadOnly )
   {
      
      // If toolBarButton1 in in the collection, remove it.
      if ( toolBar->Buttons->Contains( toolBarButton1 )
 )
      {
         toolBar->Buttons->Remove( toolBarButton1 );
      }
      
      // Create three toolbar buttons.
      ToolBarButton^ tbb1 = gcnew ToolBarButton( "tbb1" );
      ToolBarButton^ tbb2 = gcnew ToolBarButton( "tbb2" );
      ToolBarButton^ tbb3 = gcnew ToolBarButton( "tbb3" );
      
      // Add toolbar buttons to the toolbar.
      array<ToolBarButton^>^buttons = {tbb2,tbb3};
      toolBar->Buttons->AddRange( buttons );
      toolBar->Buttons->Add( "tbb4" );
      
      // Insert tbb1 into the first position in the collection.
      toolBar->Buttons->Insert( 0, tbb1 );
   }
}
private void AddToolbarButtons(ToolBar toolBar)
{
    if (!(toolBar.get_Buttons().get_IsReadOnly())) {
        // If toolBarButton1 in in the collection, remove it.
        if (toolBar.get_Buttons().Contains(toolBarButton1)) {
            toolBar.get_Buttons().Remove(toolBarButton1);
        }
        // Create three toolbar buttons.
        ToolBarButton tbb1 = new ToolBarButton("tbb1");
        ToolBarButton tbb2 = new ToolBarButton("tbb2");
        ToolBarButton tbb3 = new ToolBarButton("tbb3");
        // Add toolbar buttons to the toolbar.        
        toolBar.get_Buttons().AddRange(new ToolBarButton[] { tbb2,
 tbb3 });
        toolBar.get_Buttons().Add("tbb4");
        // Insert tbb1 into the first position in the collection.
        toolBar.get_Buttons().Insert(0, tbb1);
    }
} //AddToolbarButtons
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ToolBar.ToolBarButtonCollection クラス
ToolBar.ToolBarButtonCollection メンバ
System.Windows.Forms 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からToolBar.ToolBarButtonCollection.Contains メソッドを検索した結果を表示しています。
Weblioに収録されているすべての辞書からToolBar.ToolBarButtonCollection.Contains メソッドを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からToolBar.ToolBarButtonCollection.Contains メソッド を検索

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

辞書ショートカット

すべての辞書の索引

ToolBar.ToolBarButtonCollection.Contains メソッドのお隣キーワード
検索ランキング

   

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



ToolBar.ToolBarButtonCollection.Contains メソッドのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS