コントロールをコレクションに追加します。
Overrides Public Sub Add( _
ByVal value As Control _)
[C#]
public override void Add(Controlvalue);
[C++]
public: void Add(Control* value);
[JScript]
public override function Add(
value : Control);
パラメータ
- value
追加するコントロール。
例外
| 例外の種類 | 条件 |
|---|---|
| ArgumentException | 指定されたコントロールが TabPage です。 |
解説
指定されたコントロールがコレクションの末尾に追加されます。このコントロールが既に他のコントロールの子コントロールである場合は、他のコントロールから削除されます。
使用例
[Visual Basic, C#, C++] 1 つの TabPage が配置された TabControl を作成する例を次に示します。この例では、 Add メソッドを使用して、1 つのコントロール button1 を tabPage1 に追加しています。 Controls プロパティを使用して、 tabPage1 コントロール コレクションを取得し、このコレクションにコントロールを追加していることに注意してください。
[Visual Basic, C#, C++] この例では、 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
[C#]
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());
}
}
[C++]
using namespace System::Drawing;
using namespace System::Windows::Forms;
public __gc class Form1 : public Form {
private:
TabControl* tabControl1;
TabPage* tabPage1;
Button* button1;
public:
Form1() {
this->tabControl1 = new TabControl();
this->tabPage1 = new TabPage();
this->button1 = new 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 = S"button1";
this->button1->Location = Point(25, 25);
this->ClientSize = System::Drawing::Size(300, 300);
this->Controls->Add(tabControl1);
}
};
int main() {
Application::Run(new Form1());
}
[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン
をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
TabPage.TabPageControlCollection クラス | TabPage.TabPageControlCollection メンバ | System.Windows.Forms 名前空間