Leer en inglés

Compartir vía


TabControl.TabPageCollection.Remove(TabPage) Método

Definición

Quita una clase TabPage de la colección.

public void Remove (System.Windows.Forms.TabPage value);

Parámetros

value
TabPage

TabPage que se va a quitar.

Excepciones

El parámetro value es null.

Ejemplos

En el ejemplo de código siguiente se crea inicialmente un TabControl con tres TabPage. En este ejemplo se usa el Remove método para quitar una sola página de pestañas, específicamente tabPage2 de la tabControl1 colección controls. Observe que la TabPages propiedad obtiene la tabControl1 colección controls para agregar y quitar páginas de pestañas de esta colección.

Use los System.Drawing espacios de nombres y System.Windows.Forms con este ejemplo.

using System.Drawing;
using System.Windows.Forms;

public class Form1 : Form
{
    private TabControl tabControl1;
    private TabPage tabPage1;
    private TabPage tabPage2;
    private TabPage tabPage3;

    public Form1()
    {
        this.tabControl1 = new TabControl();
        string[] tabText = {"tabPage1", "tabPage2", "tabPage3"};
        this.tabPage1 = new TabPage(tabText[0]);
        this.tabPage2 = new TabPage(tabText[1]);
        this.tabPage3 = new TabPage(tabText[2]);

        // Populates the tabControl1 with three tab pages.
        this.tabControl1.TabPages.AddRange(new TabPage[] {
            tabPage1, tabPage2, tabPage3});

        // Gets the tabControl1 controls collection.
        // Removes the tabPage2 from the collection.
        this.tabControl1.TabPages.Remove(tabPage2);

        this.tabControl1.Location = new Point(25, 25);
        this.tabControl1.Size = new Size(250, 250);

        this.ClientSize = new Size(300, 300);
        this.Controls.Add(tabControl1);
    }

    static void Main() 
    {
        Application.Run(new Form1());
    }
}

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, 3.1, 5, 6, 7, 8, 9

Consulte también