다음을 통해 공유


ToolBar.ToolBarButtonCollection.Remove 메서드

도구 모음 단추 컬렉션에서 지정된 단추를 제거합니다.

네임스페이스: System.Windows.Forms
어셈블리: System.Windows.Forms(system.windows.forms.dll)

구문

‘선언
Public Sub Remove ( _
    button As ToolBarButton _
)
‘사용 방법
Dim instance As ToolBarButtonCollection
Dim button As ToolBarButton

instance.Remove(button)
public void Remove (
    ToolBarButton button
)
public:
void Remove (
    ToolBarButton^ button
)
public void Remove (
    ToolBarButton button
)
public function Remove (
    button : ToolBarButton
)

매개 변수

설명

컬렉션에서 도구 모음 단추를 제거하려면 RemoveAt 또는 Clear 메서드를 사용합니다.

컬렉션에 새 ToolBarButton 개체를 추가하려면 Add, AddRange 또는 Insert 메서드를 사용합니다.

예제

다음 코드 예제에서는 ToolBar 컨트롤에 기존 ToolBarButton이 있는 경우 이 단추를 제거하고 ToolBar에 네 가지 새 ToolBarButton 개체를 추가하고 삽입합니다. 이 예제를 실행하려면 FormToolBar 컨트롤이 있어야 합니다.

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에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

ToolBar.ToolBarButtonCollection 클래스
ToolBar.ToolBarButtonCollection 멤버
System.Windows.Forms 네임스페이스
Clear
ToolBarButton
Add