Upraviť

Zdieľať cez


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)

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

public:
 void Add(System::String ^ text);
public void Add (string text);
public void Add (string? text);
member this.Add : string -> unit
Public Sub Add (text As String)

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

Add(TabPage)

Adds a TabPage to the collection.

public:
 void Add(System::Windows::Forms::TabPage ^ value);
public void Add (System.Windows.Forms.TabPage value);
member this.Add : System.Windows.Forms.TabPage -> unit
Public Sub Add (value As TabPage)

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.

using namespace System::Drawing;
using namespace System::Windows::Forms;
public ref class Form1: public Form
{
private:
   TabControl^ tabControl1;
   TabPage^ tabPage1;

public:
   Form1()
   {
      this->tabControl1 = gcnew TabControl;
      this->tabPage1 = gcnew TabPage;
      
      // Gets the controls collection for tabControl1.
      // Adds the tabPage1 to this collection.
      this->tabControl1->TabPages->Add( tabPage1 );
      this->tabControl1->Location = Point(25,25);
      this->tabControl1->Size = System::Drawing::Size( 250, 250 );
      this->ClientSize = System::Drawing::Size( 300, 300 );
      this->Controls->Add( tabControl1 );
   }

};

int main()
{
   Application::Run( gcnew Form1 );
}
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());
    }
}
Imports System.Drawing
Imports System.Windows.Forms

Public Class Form1
    Inherits Form
    Private tabControl1 As TabControl
    Private tabPage1 As TabPage

    Public Sub New()
        Me.tabControl1 = New TabControl()
        Me.tabPage1 = New TabPage()

        ' Gets the controls collection for tabControl1.
        ' Adds the tabPage1 to this collection.
        Me.tabControl1.TabPages.Add(tabPage1)

        Me.tabControl1.Location = New Point(25, 25)
        Me.tabControl1.Size = New Size(250, 250)

        Me.ClientSize = New Size(300, 300)
        Me.Controls.Add(tabControl1)
    End Sub

    Shared Sub Main()
        Application.Run(New Form1())
    End Sub
End Class

See also

Applies to

Add(String, String)

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

public:
 void Add(System::String ^ key, System::String ^ text);
public void Add (string key, string text);
public void Add (string? key, string? text);
member this.Add : string * string -> unit
Public Sub Add (key As String, text As String)

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

Add(String, String, Int32)

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

public:
 void Add(System::String ^ key, System::String ^ text, int imageIndex);
public void Add (string key, string text, int imageIndex);
public void Add (string? key, string? text, int imageIndex);
member this.Add : string * string * int -> unit
Public Sub Add (key As String, text As String, imageIndex As Integer)

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

Add(String, String, String)

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

public:
 void Add(System::String ^ key, System::String ^ text, System::String ^ imageKey);
public void Add (string key, string text, string imageKey);
public void Add (string? key, string? text, string imageKey);
member this.Add : string * string * string -> unit
Public Sub Add (key As String, text As String, imageKey As String)

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