TabControl.TabPageCollection.Add 方法     
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将选项卡页添加到集合。
重载
| Add(String) | 
						   创建带有指定文本的选项卡页,并将其添加到集合。  | 
        	
| Add(TabPage) | 
						   将 TabPage 添加到集合。  | 
        	
| Add(String, String) | 
						   创建带有指定文本和键的选项卡页,并将该选项卡页添加到集合。  | 
        	
| Add(String, String, Int32) | 
						   创建带有指定键、文本和图像的选项卡页,并将该选项卡页添加到集合。  | 
        	
| Add(String, String, String) | 
						   创建带有指定键、文本和图像的选项卡页,并将该选项卡页添加到集合。  | 
        	
Add(String)
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 为 null。
示例
下面的代码示例创建一个包含一个 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 属性对应于中某个 TabPage 项的 TabControl.TabPageCollection键。
新创建的 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 属性对应于中某个 TabPage 项的 TabControl.TabPageCollection键。
该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 属性对应于中某个 TabPage 项的 TabControl.TabPageCollection键。
该imageKey参数引用属性TabControl中的ImageList图像。
新创建的 TabPage 项将添加到集合末尾。