TabPage.TabPageControlCollection.Add メソッド
アセンブリ: System.Windows.Forms (system.windows.forms.dll 内)




1 つの TabPage がある TabControl を作成するコード例を次に示します。この例では、Add メソッドを使用して、1 つのコントロール button1 を tabPage1 に追加しています。Controls プロパティを使用して、tabPage1 コントロール コレクションを取得し、このコレクションにコントロールを追加しています。
この例では、System.Drawing 名前空間と System.Windows.Forms 名前空間を使用します。
Imports System.Drawing Imports System.Windows.Forms Public Class Form1 Inherits Form Private tabControl1 As TabControl Private tabPage1 As TabPage Private button1 As Button Public Sub New() Me.tabControl1 = New TabControl() Me.tabPage1 = New TabPage() Me.button1 = New Button() Me.tabControl1.TabPages.Add(tabPage1) Me.tabControl1.Location = New Point(25, 25) Me.tabControl1.Size = New Size(250, 250) ' Gets the controls collection for tabPage1. ' Adds button1 to this collection. Me.tabPage1.Controls.Add(button1) Me.button1.Text = "button1" Me.button1.Location = New Point(25, 25) Me.ClientSize = New Size(300, 300) Me.Controls.Add(tabControl1) End Sub Shared Sub Main() Application.Run(New Form1()) End Sub End Class
using System.Drawing; using System.Windows.Forms; public class Form1 : Form { private TabControl tabControl1; private TabPage tabPage1; private Button button1; public Form1() { this.tabControl1 = new TabControl(); this.tabPage1 = new TabPage(); this.button1 = new Button(); this.tabControl1.TabPages.Add(tabPage1); this.tabControl1.Location = new Point(25, 25); this.tabControl1.Size = new Size(250, 250); // Gets the controls collection for tabPage1. // Adds button1 to this collection. this.tabPage1.Controls.Add(button1); this.button1.Text = "button1"; this.button1.Location = new Point(25, 25); this.ClientSize = new Size(300, 300); this.Controls.Add(tabControl1); } static void Main() { Application.Run(new Form1()); } }
using namespace System::Drawing; using namespace System::Windows::Forms; public ref class Form1: public Form { private: TabControl^ tabControl1; TabPage^ tabPage1; Button^ button1; public: Form1() { this->tabControl1 = gcnew TabControl; this->tabPage1 = gcnew TabPage; this->button1 = gcnew Button; this->tabControl1->TabPages->Add( tabPage1 ); this->tabControl1->Location = Point(25,25); this->tabControl1->Size = System::Drawing::Size( 250, 250 ); // Gets the controls collection for tabPage1. // Adds button1 to this collection. this->tabPage1->Controls->Add( button1 ); this->button1->Text = "button1"; this->button1->Location = Point(25,25); this->ClientSize = System::Drawing::Size( 300, 300 ); this->Controls->Add( tabControl1 ); } }; int main() { Application::Run( gcnew Form1 ); }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


TabPage.TabPageControlCollection クラス
TabPage.TabPageControlCollection メンバ
System.Windows.Forms 名前空間
- TabPage.TabPageControlCollection.Add メソッドのページへのリンク