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


nodes 配列に格納されている ToolBarButton オブジェクトが、コレクションの末尾に追加されます。
このメソッドを使用すると、Add メソッドを使用して個別の ToolBarButton を手動でコレクションに追加するのではなく、以前作成した ToolBarButton オブジェクトのグループをすばやくコレクションに追加できます。
以前追加した ToolBarButton を削除するには、Remove メソッド、RemoveAt メソッド、または Clear メソッドを使用します。

存在する場合は 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.AddRange メソッドを検索する場合は、下記のリンクをクリックしてください。

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