TabControl クラス
関連する一連のタブ ページを管理します。
この型のすべてのメンバの一覧については、TabControl メンバ を参照してください。
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Control
System.Windows.Forms.TabControl
Public Class TabControl
Inherits Control
[C#]
public class TabControl : Control
[C++]
public __gc class TabControl : public Control
[JScript]
public class TabControl extends Control
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
解説
TabControl はタブ ページを格納しています。これらのタブ ページは、 Controls プロパティを使用して追加する TabPage オブジェクトで表されます。
メモ Control.Click 、 Control.DoubleClick 、 Control.MouseDown 、 Control.MouseUp 、 Control.MouseHover 、 Control.MouseEnter 、 Control.MouseLeave 、 Control.MouseMove の各イベントは、 TabControl.TabPages コレクションの 1 つ以上の TabPage が存在しない限り、 TabControl クラスで生成されません。コレクションに 1 つ以上の TabPage があり、ユーザーがタブ コントロールのヘッダー (TabPage の名前が表示される場所) と対話すると、 TabControl が適切なイベントを発生させます。ただし、ユーザーとの対話がタブ ページの ClientRectangle 内の場合、 TabPage は該当するイベントを発生させます。
使用例
[Visual Basic, C#, C++] Visual Studio .NET Windows フォーム デザイナを使用して、3 つのタブ ページがある TabControl を作成する例を次に示します。各タブ ページは、コントロールをいくつか保持しています。
Public Class Form1
Inherits System.Windows.Forms.Form
' Required designer variable.
Private components As System.ComponentModel.Container
' Declares variables.
Private tab3RadioButton2 As System.Windows.Forms.RadioButton
Private tab3RadioButton1 As System.Windows.Forms.RadioButton
Private tab2CheckBox3 As System.Windows.Forms.CheckBox
Private tab2CheckBox2 As System.Windows.Forms.CheckBox
Private tab2CheckBox1 As System.Windows.Forms.CheckBox
Private tab1Label1 As System.Windows.Forms.Label
Private WithEvents tab1Button1 As System.Windows.Forms.Button
Private tabPage3 As System.Windows.Forms.TabPage
Private tabPage2 As System.Windows.Forms.TabPage
Private tabPage1 As System.Windows.Forms.TabPage
Private tabControl1 As System.Windows.Forms.TabControl
Public Sub New()
' This call is required for Windows Form Designer support.
InitializeComponent()
End Sub
' This method is required for Designer support.
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.tabPage1 = New System.Windows.Forms.TabPage()
Me.tab2CheckBox3 = New System.Windows.Forms.CheckBox()
Me.tab3RadioButton2 = New System.Windows.Forms.RadioButton()
Me.tabControl1 = New System.Windows.Forms.TabControl()
Me.tab2CheckBox2 = New System.Windows.Forms.CheckBox()
Me.tab2CheckBox1 = New System.Windows.Forms.CheckBox()
Me.tab3RadioButton1 = New System.Windows.Forms.RadioButton()
Me.tab1Label1 = New System.Windows.Forms.Label()
Me.tabPage3 = New System.Windows.Forms.TabPage()
Me.tabPage2 = New System.Windows.Forms.TabPage()
Me.tab1Button1 = New System.Windows.Forms.Button()
tabPage1.Text = "tabPage1"
tabPage1.Size = New System.Drawing.Size(256, 214)
tabPage1.TabIndex = 0
tab2CheckBox3.Location = New System.Drawing.Point(32, 136)
tab2CheckBox3.Text = "checkBox3"
tab2CheckBox3.Size = New System.Drawing.Size(176, 32)
tab2CheckBox3.TabIndex = 2
tab2CheckBox3.Visible = True
tab3RadioButton2.Location = New System.Drawing.Point(40, 72)
tab3RadioButton2.Text = "radioButton2"
tab3RadioButton2.Size = New System.Drawing.Size(152, 24)
tab3RadioButton2.TabIndex = 1
tab3RadioButton2.Visible = True
tabControl1.Location = New System.Drawing.Point(16, 16)
tabControl1.Size = New System.Drawing.Size(264, 240)
tabControl1.SelectedIndex = 0
tabControl1.TabIndex = 0
tab2CheckBox2.Location = New System.Drawing.Point(32, 80)
tab2CheckBox2.Text = "checkBox2"
tab2CheckBox2.Size = New System.Drawing.Size(176, 32)
tab2CheckBox2.TabIndex = 1
tab2CheckBox2.Visible = True
tab2CheckBox1.Location = New System.Drawing.Point(32, 24)
tab2CheckBox1.Text = "checkBox1"
tab2CheckBox1.Size = New System.Drawing.Size(176, 32)
tab2CheckBox1.TabIndex = 0
tab3RadioButton1.Location = New System.Drawing.Point(40, 32)
tab3RadioButton1.Text = "radioButton1"
tab3RadioButton1.Size = New System.Drawing.Size(152, 24)
tab3RadioButton1.TabIndex = 0
tab1Label1.Location = New System.Drawing.Point(16, 24)
tab1Label1.Text = "label1"
tab1Label1.Size = New System.Drawing.Size(224, 96)
tab1Label1.TabIndex = 1
tabPage3.Text = "tabPage3"
tabPage3.Size = New System.Drawing.Size(256, 214)
tabPage3.TabIndex = 2
tabPage2.Text = "tabPage2"
tabPage2.Size = New System.Drawing.Size(256, 214)
tabPage2.TabIndex = 1
tab1Button1.Location = New System.Drawing.Point(88, 144)
tab1Button1.Size = New System.Drawing.Size(80, 40)
tab1Button1.TabIndex = 0
tab1Button1.Text = "button1"
Me.Text = "Form1"
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
' Adds controls to the second tab page.
tabPage2.Controls.Add(Me.tab2CheckBox3)
tabPage2.Controls.Add(Me.tab2CheckBox2)
tabPage2.Controls.Add(Me.tab2CheckBox1)
' Adds controls to the third tab page.
tabPage3.Controls.Add(Me.tab3RadioButton2)
tabPage3.Controls.Add(Me.tab3RadioButton1)
' Adds controls to the first tab page.
tabPage1.Controls.Add(Me.tab1Label1)
tabPage1.Controls.Add(Me.tab1Button1)
' Adds the TabControl to the form.
Me.Controls.Add(tabControl1)
' Adds the tab pages to the TabControl.
tabControl1.Controls.Add(Me.tabPage1)
tabControl1.Controls.Add(Me.tabPage2)
tabControl1.Controls.Add(Me.tabPage3)
End Sub
Private Sub tab1Button1_Click(sender As Object, e As System.EventArgs) _
Handles tab1Button1.Click
' Inserts the code that should run when the button is clicked.
End Sub
Public Shared Sub Main()
Application.Run(New Form1())
End Sub
End Class
[C#]
public class Form1 : System.Windows.Forms.Form
{
// Required designer variable.
private System.ComponentModel.Container components;
// Declare variables.
private System.Windows.Forms.RadioButton tab3RadioButton2;
private System.Windows.Forms.RadioButton tab3RadioButton1;
private System.Windows.Forms.CheckBox tab2CheckBox3;
private System.Windows.Forms.CheckBox tab2CheckBox2;
private System.Windows.Forms.CheckBox tab2CheckBox1;
private System.Windows.Forms.Label tab1Label1;
private System.Windows.Forms.Button tab1Button1;
private System.Windows.Forms.TabPage tabPage3;
private System.Windows.Forms.TabPage tabPage2;
private System.Windows.Forms.TabPage tabPage1;
private System.Windows.Forms.TabControl tabControl1;
public Form1()
{
// This call is required for Windows Form Designer support.
InitializeComponent();
}
// This method is required for Designer support.
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.tabPage1 = new System.Windows.Forms.TabPage();
this.tab2CheckBox3 = new System.Windows.Forms.CheckBox();
this.tab3RadioButton2 = new System.Windows.Forms.RadioButton();
this.tabControl1 = new System.Windows.Forms.TabControl();
this.tab2CheckBox2 = new System.Windows.Forms.CheckBox();
this.tab2CheckBox1 = new System.Windows.Forms.CheckBox();
this.tab3RadioButton1 = new System.Windows.Forms.RadioButton();
this.tab1Label1 = new System.Windows.Forms.Label();
this.tabPage3 = new System.Windows.Forms.TabPage();
this.tabPage2 = new System.Windows.Forms.TabPage();
this.tab1Button1 = new System.Windows.Forms.Button();
tabPage1.Text = "tabPage1";
tabPage1.Size = new System.Drawing.Size(256, 214);
tabPage1.TabIndex = 0;
tab2CheckBox3.Location = new System.Drawing.Point(32, 136);
tab2CheckBox3.Text = "checkBox3";
tab2CheckBox3.Size = new System.Drawing.Size(176, 32);
tab2CheckBox3.TabIndex = 2;
tab2CheckBox3.Visible = true;
tab3RadioButton2.Location = new System.Drawing.Point(40, 72);
tab3RadioButton2.Text = "radioButton2";
tab3RadioButton2.Size = new System.Drawing.Size(152, 24);
tab3RadioButton2.TabIndex = 1;
tab3RadioButton2.Visible = true;
tabControl1.Location = new System.Drawing.Point(16, 16);
tabControl1.Size = new System.Drawing.Size(264, 240);
tabControl1.SelectedIndex = 0;
tabControl1.TabIndex = 0;
tab2CheckBox2.Location = new System.Drawing.Point(32, 80);
tab2CheckBox2.Text = "checkBox2";
tab2CheckBox2.Size = new System.Drawing.Size(176, 32);
tab2CheckBox2.TabIndex = 1;
tab2CheckBox2.Visible = true;
tab2CheckBox1.Location = new System.Drawing.Point(32, 24);
tab2CheckBox1.Text = "checkBox1";
tab2CheckBox1.Size = new System.Drawing.Size(176, 32);
tab2CheckBox1.TabIndex = 0;
tab3RadioButton1.Location = new System.Drawing.Point(40, 32);
tab3RadioButton1.Text = "radioButton1";
tab3RadioButton1.Size = new System.Drawing.Size(152, 24);
tab3RadioButton1.TabIndex = 0;
tab1Label1.Location = new System.Drawing.Point(16, 24);
tab1Label1.Text = "label1";
tab1Label1.Size = new System.Drawing.Size(224, 96);
tab1Label1.TabIndex = 1;
tabPage3.Text = "tabPage3";
tabPage3.Size = new System.Drawing.Size(256, 214);
tabPage3.TabIndex = 2;
tabPage2.Text = "tabPage2";
tabPage2.Size = new System.Drawing.Size(256, 214);
tabPage2.TabIndex = 1;
tab1Button1.Location = new System.Drawing.Point(88, 144);
tab1Button1.Size = new System.Drawing.Size(80, 40);
tab1Button1.TabIndex = 0;
tab1Button1.Text = "button1";
tab1Button1.Click += new
System.EventHandler(this.tab1Button1_Click);
this.Text = "Form1";
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
// Adds controls to the second tab page.
tabPage2.Controls.Add(this.tab2CheckBox3);
tabPage2.Controls.Add(this.tab2CheckBox2);
tabPage2.Controls.Add(this.tab2CheckBox1);
// Adds controls to the third tab page.
tabPage3.Controls.Add(this.tab3RadioButton2);
tabPage3.Controls.Add(this.tab3RadioButton1);
// Adds controls to the first tab page.
tabPage1.Controls.Add(this.tab1Label1);
tabPage1.Controls.Add(this.tab1Button1);
// Adds the TabControl to the form.
this.Controls.Add(this.tabControl1);
// Adds the tab pages to the TabControl.
tabControl1.Controls.Add(this.tabPage1);
tabControl1.Controls.Add(this.tabPage2);
tabControl1.Controls.Add(this.tabPage3);
}
private void tab1Button1_Click (object sender, System.EventArgs e)
{
// Inserts the code that should run when the button is clicked.
}
public static void Main(string[] args)
{
Application.Run(new Form1());
}
}
[C++]
public __gc class Form1 : public System::Windows::Forms::Form
{
// Required designer variable.
private:
System::ComponentModel::Container* components;
// Declare variables.
System::Windows::Forms::RadioButton* tab3RadioButton2;
System::Windows::Forms::RadioButton* tab3RadioButton1;
System::Windows::Forms::CheckBox* tab2CheckBox3;
System::Windows::Forms::CheckBox* tab2CheckBox2;
System::Windows::Forms::CheckBox* tab2CheckBox1;
System::Windows::Forms::Label* tab1Label1;
System::Windows::Forms::Button* tab1Button1;
System::Windows::Forms::TabPage* tabPage3;
System::Windows::Forms::TabPage* tabPage2;
System::Windows::Forms::TabPage* tabPage1;
System::Windows::Forms::TabControl* tabControl1;
public:
Form1()
{
// This call is required for Windows Form Designer support.
InitializeComponent();
}
// This method is required for Designer support.
private:
void InitializeComponent()
{
this->components = new System::ComponentModel::Container();
this->tabPage1 = new System::Windows::Forms::TabPage();
this->tab2CheckBox3 = new System::Windows::Forms::CheckBox();
this->tab3RadioButton2 = new System::Windows::Forms::RadioButton();
this->tabControl1 = new System::Windows::Forms::TabControl();
this->tab2CheckBox2 = new System::Windows::Forms::CheckBox();
this->tab2CheckBox1 = new System::Windows::Forms::CheckBox();
this->tab3RadioButton1 = new System::Windows::Forms::RadioButton();
this->tab1Label1 = new System::Windows::Forms::Label();
this->tabPage3 = new System::Windows::Forms::TabPage();
this->tabPage2 = new System::Windows::Forms::TabPage();
this->tab1Button1 = new System::Windows::Forms::Button();
tabPage1->Text = S"tabPage1";
tabPage1->Size = System::Drawing::Size(256, 214);
tabPage1->TabIndex = 0;
tab2CheckBox3->Location = System::Drawing::Point(32, 136);
tab2CheckBox3->Text = S"checkBox3";
tab2CheckBox3->Size = System::Drawing::Size(176, 32);
tab2CheckBox3->TabIndex = 2;
tab2CheckBox3->Visible = true;
tab3RadioButton2->Location = System::Drawing::Point(40, 72);
tab3RadioButton2->Text = S"radioButton2";
tab3RadioButton2->Size = System::Drawing::Size(152, 24);
tab3RadioButton2->TabIndex = 1;
tab3RadioButton2->Visible = true;
tabControl1->Location = System::Drawing::Point(16, 16);
tabControl1->Size = System::Drawing::Size(264, 240);
tabControl1->SelectedIndex = 0;
tabControl1->TabIndex = 0;
tab2CheckBox2->Location = System::Drawing::Point(32, 80);
tab2CheckBox2->Text = S"checkBox2";
tab2CheckBox2->Size = System::Drawing::Size(176, 32);
tab2CheckBox2->TabIndex = 1;
tab2CheckBox2->Visible = true;
tab2CheckBox1->Location = System::Drawing::Point(32, 24);
tab2CheckBox1->Text = S"checkBox1";
tab2CheckBox1->Size = System::Drawing::Size(176, 32);
tab2CheckBox1->TabIndex = 0;
tab3RadioButton1->Location = System::Drawing::Point(40, 32);
tab3RadioButton1->Text = S"radioButton1";
tab3RadioButton1->Size = System::Drawing::Size(152, 24);
tab3RadioButton1->TabIndex = 0;
tab1Label1->Location = System::Drawing::Point(16, 24);
tab1Label1->Text = S"label1";
tab1Label1->Size = System::Drawing::Size(224, 96);
tab1Label1->TabIndex = 1;
tabPage3->Text = S"tabPage3";
tabPage3->Size = System::Drawing::Size(256, 214);
tabPage3->TabIndex = 2;
tabPage2->Text = S"tabPage2";
tabPage2->Size = System::Drawing::Size(256, 214);
tabPage2->TabIndex = 1;
tab1Button1->Location = System::Drawing::Point(88, 144);
tab1Button1->Size = System::Drawing::Size(80, 40);
tab1Button1->TabIndex = 0;
tab1Button1->Text = S"button1";
tab1Button1->Click += new
System::EventHandler(this, &Form1::tab1Button1_Click);
this->Text = S"Form1";
this->AutoScaleBaseSize = System::Drawing::Size(5, 13);
// Adds controls to the second tab page.
tabPage2->Controls->Add(this->tab2CheckBox3);
tabPage2->Controls->Add(this->tab2CheckBox2);
tabPage2->Controls->Add(this->tab2CheckBox1);
// Adds controls to the third tab page.
tabPage3->Controls->Add(this->tab3RadioButton2);
tabPage3->Controls->Add(this->tab3RadioButton1);
// Adds controls to the first tab page.
tabPage1->Controls->Add(this->tab1Label1);
tabPage1->Controls->Add(this->tab1Button1);
// Adds the TabControl to the form.
this->Controls->Add(this->tabControl1);
// Adds the tab pages to the TabControl.
tabControl1->Controls->Add(this->tabPage1);
tabControl1->Controls->Add(this->tabPage2);
tabControl1->Controls->Add(this->tabPage3);
}
void tab1Button1_Click (Object* /*sender*/, System::EventArgs* /*e*/)
{
// Inserts the code that should run when the button is clicked.
}
};
int main()
{
Application::Run(new Form1());
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Windows.Forms
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET
アセンブリ: System.Windows.Forms (System.Windows.Forms.dll 内)