This documentation is archived and is not being maintained.

TabControl.TabPageCollection.Remove Method

Removes a TabPage from the collection.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public void Remove (
	TabPage value
)
public void Remove (
	TabPage value
)
public function Remove (
	value : TabPage
)

Parameters

value

The TabPage to remove.

Exception typeCondition

ArgumentNullException

The value parameter is a null reference (Nothing in Visual Basic).

The following code example initially creates a TabControl with three TabPage. This example uses the Remove method to remove a single tab page, specifically tabPage2 from the tabControl1 controls collection. Notice that the TabPages property gets the tabControl1 controls collection to add and remove tab pages from this collection.

Use the System.Drawing and System.Windows.Forms namespaces with this example.

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());
    }
}

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

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0
Show: