TabControl.TabPages Property

Definition

Gets the collection of tab pages in this tab control.

C#
public System.Windows.Forms.TabControl.TabPageCollection TabPages { get; }

Property Value

A TabControl.TabPageCollection that contains the TabPage objects in this TabControl.

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

Remarks

The order of tab pages in this collection reflects the order the tabs appear in the control.

Applies to

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

See also