Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

TabPage Class

Represents a single tab page in a TabControl.

For a list of all members of this type, see TabPage Members.

System.Object
   System.MarshalByRefObject
      System.ComponentModel.Component
         System.Windows.Forms.Control
            System.Windows.Forms.ScrollableControl
               System.Windows.Forms.Panel
                  System.Windows.Forms.TabPage

[Visual Basic]
Public Class TabPage
   Inherits Panel
[C#]
public class TabPage : Panel
[C++]
public __gc class TabPage : public Panel
[JScript]
public class TabPage extends Panel

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

For more information about how this control responds to the Focus and Select methods, see the following Control members: CanFocus, CanSelect, Focused, ContainsFocus, Focus, Select.

Example

[Visual Basic, C#, C++] The following example creates a TabControl with one TabPage.

[Visual Basic, C#, C++] Use the System.Drawing and System.Windows.Forms namespaces for this example.

[Visual Basic] 
Imports System.Drawing
Imports System.Windows.Forms

Public Class Form1
    Inherits Form
    Private tabControl1 As TabControl

    ' Declares tabPage1 as a TabPage type.
    Private tabPage1 As System.Windows.Forms.TabPage

    Private Sub MyTabs()
        Me.tabControl1 = New TabControl()

        ' Invokes the TabPage() constructor to create the tabPage1.
        Me.tabPage1 = New System.Windows.Forms.TabPage()

        Me.tabControl1.Controls.AddRange(New Control() {Me.tabPage1})
        Me.tabControl1.Location = New Point(25, 25)
        Me.tabControl1.Size = New Size(250, 250)

        Me.ClientSize = New Size(300, 300)
        Me.Controls.AddRange(New Control() {Me.tabControl1})
    End Sub

    Public Sub New()
        MyTabs()
    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;

    // Declares tabPage1 as a TabPage type.
    private System.Windows.Forms.TabPage tabPage1;

    private void MyTabs()
    {
        this.tabControl1 = new TabControl();

        // Invokes the TabPage() constructor to create the tabPage1.
        this.tabPage1 = new System.Windows.Forms.TabPage();

        this.tabControl1.Controls.AddRange(new Control[] {
            this.tabPage1});
        this.tabControl1.Location = new Point(25, 25);
        this.tabControl1.Size = new Size(250, 250);

        this.ClientSize = new Size(300, 300);
        this.Controls.AddRange(new Control[] {
            this.tabControl1});
    }

    public Form1()
    {
        MyTabs();
    }

    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;

    // Declares tabPage1 as a TabPage type.
    System::Windows::Forms::TabPage*  tabPage1;

    void MyTabs() {
        this->tabControl1 = new TabControl();

        // Invokes the TabPage() constructor to create the tabPage1.
        this->tabPage1 = new System::Windows::Forms::TabPage();

        Control* tabControls[] = {this->tabPage1};
        this->tabControl1->Controls->AddRange(tabControls);
        this->tabControl1->Location = Point(25, 25);
        this->tabControl1->Size = System::Drawing::Size(250, 250);
        this->ClientSize = System::Drawing::Size(300, 300);
        Control* formControls[] = {this->tabControl1};
        this->Controls->AddRange(formControls);
    }

public:
    Form1() {
        MyTabs();
    }
};

int main() {
    Application::Run(new Form1());
}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Windows.Forms

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: System.Windows.Forms (in System.Windows.Forms.dll)

See Also

TabPage Members | System.Windows.Forms Namespace | TabControl

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.