ToolBar.ToolBarButtonCollection.Remove(ToolBarButton) Método

Definición

Quita un botón determinado de la colección de botones de barra de herramientas.

C#
public void Remove(System.Windows.Forms.ToolBarButton button);

Parámetros

button
ToolBarButton

ToolBarButton que se va a quitar de la colección.

Ejemplos

En el ejemplo de código siguiente se quita un existente ToolBarButton de un ToolBar control si existe y se agregan e insertan cuatro objetos nuevos ToolBarButton en .ToolBar En este ejemplo se requiere que tenga un Form con un ToolBar control en él.

C#
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);
   }
}

Comentarios

Para quitar botones de la barra de herramientas de la colección, use los RemoveAtmétodos , o Clear .

Para agregar nuevos ToolBarButton objetos a la colección, use los Addmétodos , AddRange o Insert .

Se aplica a

Producto Versiones
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 10

Consulte también