语言

TabControl.TabPageCollection.Add 方法

定义

将选项卡页添加到集合。

重载

名称 说明
Add(String)

创建包含指定文本的选项卡页,并将其添加到集合中。

Add(TabPage)

将 a TabPage 添加到集合。

Add(String, String)

创建具有指定文本和键的选项卡页,并将其添加到集合中。

Add(String, String, Int32)

创建具有指定键、文本和图像的选项卡页,并将其添加到集合中。

Add(String, String, String)

创建具有指定键、文本和图像的选项卡页,并将其添加到集合中。

Add(String)

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

创建包含指定文本的选项卡页,并将其添加到集合中。

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)

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

将 a 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 添加的。

例外

指定的 value 是 null。

示例

下面的代码示例创建一个包含一个 TabControlTabPage。 此示例使用 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)

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

创建具有指定文本和键的选项卡页,并将其添加到集合中。

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 属性对应于中某个 TabPage 项的 TabControl.TabPageCollection键。

新创建的 TabPage 项将添加到集合的末尾。

适用于

Add(String, String, Int32)

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

创建具有指定键、文本和图像的选项卡页,并将其添加到集合中。

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 属性对应于中某个 TabPage 项的 TabControl.TabPageCollection键。

该imageIndex参数引用属性ImageList中的TabControl图像。

新创建的 TabPage 项将添加到集合的末尾。

适用于

Add(String, String, String)

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

创建具有指定键、文本和图像的选项卡页,并将其添加到集合中。

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 属性对应于中某个 TabPage 项的 TabControl.TabPageCollection键。

该imageKey参数引用属性ImageList中的TabControl图像。

新创建的 TabPage 项将添加到集合的末尾。

适用于