TabControl.TabPageCollection.Add 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
為收藏新增一個分頁頁。
多載
| 名稱 | Description |
|---|---|
| Add(String) |
建立一個標籤頁,包含指定的文字,並將其加入收藏。 |
| Add(TabPage) |
為收藏增添 a TabPage 。 |
| Add(String, String) |
建立一個分頁頁,包含指定的文字和鍵,並將其加入收藏。 |
| Add(String, String, Int32) |
建立一個分頁頁面,包含指定的鍵、文字和圖片,並將其加入集合。 |
| Add(String, String, String) |
建立一個分頁頁面,包含指定的鍵、文字和圖片,並將其加入集合。 |
Add(TabPage)
為收藏增添 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 為 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性質對應於 中 a 的TabPageTabControl.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性質對應於 中 a 的TabPageTabControl.TabPageCollection鍵。
參數imageIndex指的是屬性中的ImageListTabControl影像。
新創建 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性質對應於 中 a 的TabPageTabControl.TabPageCollection鍵。
參數imageKey指的是屬性中的ImageListTabControl影像。
新創建 TabPage 的會被加入收藏的末尾。