TabControl.TabPageCollection.Add 方法

定義

將索引標籤頁加入集合中。

多載

Add(String)

使用指定文字建立索引標籤頁,並將它加入集合中。

Add(TabPage)

TabPage 加入集合。

Add(String, String)

使用指定文字和索引鍵建立索引標籤頁,並將它加入集合中。

Add(String, String, Int32)

使用指定的索引鍵、文字和影像建立索引標籤頁,並將它加入至集合中。

Add(String, String, String)

使用指定的索引鍵、文字和影像建立索引標籤頁,並將它加入至集合中。

Add(String)

使用指定文字建立索引標籤頁,並將它加入集合中。

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)

參數

text
String

要顯示在索引標籤頁上的文字。

備註

新建立 TabPage 的 會新增至集合結尾。

適用於

Add(TabPage)

TabPage 加入集合。

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)

參數

value
TabPage

要加入的 TabPage

例外狀況

指定的 valuenull

範例

下列程式碼範例會使用一個 TabControl TabPage 來建立 。 此範例會 Add 使用 方法,將單一索引標籤頁面新增至 tabControl1 索引標籤控制項。 請注意, TabPages 屬性是用來取得 tabControl1 控制項集合,以將 加入 tabPage1 至這個集合。

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

另請參閱

適用於

Add(String, String)

使用指定文字和索引鍵建立索引標籤頁,並將它加入集合中。

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)

參數

key
String

索引標籤頁的名稱。

text
String

要顯示在索引標籤頁上的文字。

備註

屬性 Name 會對應至 中的 索引 TabControl.TabPageCollectionTabPage

新建立 TabPage 的 會新增至集合結尾。

適用於

Add(String, String, Int32)

使用指定的索引鍵、文字和影像建立索引標籤頁,並將它加入至集合中。

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)

參數

key
String

索引標籤頁的名稱。

text
String

要顯示在索引標籤頁上的文字。

imageIndex
Int32

要顯示在索引標籤頁上的影像索引。

備註

屬性 Name 會對應至 中的 索引 TabControl.TabPageCollectionTabPage

參數 imageIndex 參考 的 屬性 TabControl 中的 ImageList 影像。

新建立 TabPage 的 會新增至集合結尾。

適用於

Add(String, String, String)

使用指定的索引鍵、文字和影像建立索引標籤頁,並將它加入至集合中。

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)

參數

key
String

索引標籤頁的名稱。

text
String

要顯示在索引標籤頁上的文字。

imageKey
String

要顯示在索引標籤頁上的影像之索引鍵。

備註

屬性 Name 會對應至 中的 索引 TabControl.TabPageCollectionTabPage

參數 imageKey 參考 的 屬性 TabControl 中的 ImageList 影像。

新建立 TabPage 的 會新增至集合結尾。

適用於