ToolBar.ToolBarButtonCollection.Contains メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)

Dim instance As ToolBarButtonCollection Dim button As ToolBarButton Dim returnValue As Boolean returnValue = instance.Contains(button)
戻り値
ToolBarButton がコレクションのメンバの場合は true。それ以外の場合は false。

このメソッドを使用すると、ToolBarButton に対して操作を実行する前に、ToolBarButton がコレクションのメンバかどうかを確認できます。このメソッドを使用して、ToolBarButton がコレクションに追加されたことや、依然としてコレクションのメンバであることを確認できます。

存在する場合は 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

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からToolBar.ToolBarButtonCollection.Contains メソッドを検索する場合は、下記のリンクをクリックしてください。

- ToolBar.ToolBarButtonCollection.Contains メソッドのページへのリンク