TabPage.TabPageControlCollection.Add Method (Control)


Adds a control to the collection.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public override void Add(
	Control value


Type: System.Windows.Forms.Control

The control to add.

Exception Condition

The specified control is a TabPage.

The specified control is added to the end of the collection. If the control is already a child of another control, it is removed from the other control.

The following code example creates a TabControl with one TabPage. This example uses the Add method to add a single control, button1, to the tabPage1. The Controls property is used to get the tabPage1 controls collection to add controls to the collection.

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

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

public class Form1 : Form
    private TabControl tabControl1;
    private TabPage tabPage1;
    private Button button1;

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

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

        // Gets the controls collection for tabPage1.
        // Adds button1 to this collection.

        this.button1.Text = "button1";
        this.button1.Location = new Point(25, 25);

        this.ClientSize = new Size(300, 300);

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

.NET Framework
Available since 1.1
Return to top