TabPage Class
Represents a single tab page in a TabControl.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
TabPage controls represent the tabbed pages in a TabControl control. The order of tab pages in the TabControl.TabPages collection reflects the order of tabs in the TabControl control. To change the order of tabs in the control, you must change their positions in the collection by removing them and inserting them at new indexes.
TabPage controls are constrained by their container, so some of the properties inherited from the Control base class will have no effect, including Top, Height, Left, Width, Show, and Hide.
The tabs in a TabControl are part of the TabControl but not parts of the individual TabPage controls. Members of the TabPage class, such as the ForeColor property, affect only the client rectangle of the tab page, but not the tabs. Additionally, the Hide method of the TabPage will not hide the tab. To hide the tab, you must remove the TabPage control from the TabControl.TabPages collection.
Note: |
|---|
In .NET Framework version 2.0, the tab is considered part of the tab page for determining when the Enter and Leave events of the TabPage occur. In earlier versions of the .NET Framework, the Enter and Leave events of the TabPage do not occur when focus enters or leaves a tab, but only when focus enters or leaves the client rectangle of the tab page. |
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.
Note: |
|---|
Controls contained in a TabPage are not created until the tab page is shown, and any data bindings in these controls are not activated until the tab page is shown. |
In .NET Framework version 2.0, the UseVisualStyleBackColor property lets you indicate whether the background of the tab page should render using the current visual style. This occurs only when the UseVisualStyleBackColor and Application.RenderWithVisualStyles property values are both true and the Appearance property of the parent TabControl is Normal. Otherwise, the background is painted normally.
The following code example creates a TabControl with one TabPage.
Use the System.Drawing and System.Windows.Forms namespaces for this example.
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
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Pocket PC
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note: