TabControl.TabPageCollection.Add Method

Definition

Adds a tab page to the collection.

Overloads

Add(String)

Creates a tab page with the specified text, and adds it to the collection.

Add(TabPage)

Adds a TabPage to the collection.

Add(String, String)

Creates a tab page with the specified text and key, and adds it to the collection.

Add(String, String, Int32)

Creates a tab page with the specified key, text, and image, and adds it to the collection.

Add(String, String, String)

Creates a tab page with the specified key, text, and image, and adds it to the collection.

Add(String)

Source:
TabControl.TabPageCollection.cs
Source:
TabControl.TabPageCollection.cs
Source:
TabControl.TabPageCollection.cs

Creates a tab page with the specified text, and adds it to the collection.

C#
public void Add(string text);
C#
public void Add(string? text);

Parameters

text
String

The text to display on the tab page.

Remarks

The newly created TabPage is added to the end of the collection.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 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

Add(TabPage)

Source:
TabControl.TabPageCollection.cs
Source:
TabControl.TabPageCollection.cs
Source:
TabControl.TabPageCollection.cs

Adds a TabPage to the collection.

C#
public void Add(System.Windows.Forms.TabPage value);

Parameters

value
TabPage

The TabPage to add.

Exceptions

The specified value is null.

Examples

The following code example creates a TabControl with one TabPage. This example uses the Add method to add a single tab page to the tabControl1 tab control. Notice the TabPages property is used to get the tabControl1 controls collection to add the tabPage1 to this collection.

C#
using System.Drawing;
using System.Windows.Forms;

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

    public Form1()
    {
        this.tabControl1 = new TabControl();
        this.tabPage1 = new TabPage();

        // Gets the controls collection for tabControl1.
        // Adds the tabPage1 to this collection.
        this.tabControl1.TabPages.Add(tabPage1);

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

See also

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.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

Add(String, String)

Source:
TabControl.TabPageCollection.cs
Source:
TabControl.TabPageCollection.cs
Source:
TabControl.TabPageCollection.cs

Creates a tab page with the specified text and key, and adds it to the collection.

C#
public void Add(string key, string text);
C#
public void Add(string? key, string? text);

Parameters

key
String

The name of the tab page.

text
String

The text to display on the tab page.

Remarks

The Name property corresponds to the key for a TabPage in the TabControl.TabPageCollection.

The newly created TabPage is added to the end of the collection.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 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

Add(String, String, Int32)

Source:
TabControl.TabPageCollection.cs
Source:
TabControl.TabPageCollection.cs
Source:
TabControl.TabPageCollection.cs

Creates a tab page with the specified key, text, and image, and adds it to the collection.

C#
public void Add(string key, string text, int imageIndex);
C#
public void Add(string? key, string? text, int imageIndex);

Parameters

key
String

The name of the tab page.

text
String

The text to display on the tab page.

imageIndex
Int32

The index of the image to display on the tab page.

Remarks

The Name property corresponds to the key for a TabPage in the TabControl.TabPageCollection.

The imageIndex parameter refers to an image in the ImageList property of the TabControl.

The newly created TabPage is added to the end of the collection.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 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

Add(String, String, String)

Source:
TabControl.TabPageCollection.cs
Source:
TabControl.TabPageCollection.cs
Source:
TabControl.TabPageCollection.cs

Creates a tab page with the specified key, text, and image, and adds it to the collection.

C#
public void Add(string key, string text, string imageKey);
C#
public void Add(string? key, string? text, string imageKey);

Parameters

key
String

The name of the tab page.

text
String

The text to display on the tab page.

imageKey
String

The key of the image to display on the tab page.

Remarks

The Name property corresponds to the key for a TabPage in the TabControl.TabPageCollection.

The imageKey parameter refers to an image in the ImageList property of the TabControl.

The newly created TabPage is added to the end of the collection.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 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