A TabControl contains tab pages, which are represented by TabPage objects that you add through the TabPages property. The order of tab pages in this collection reflects the order the tabs appear in the control.
The user can change the current TabPage by clicking one of the tabs in the control. You can also programmatically change the current TabPage by using one of the following TabControl properties:
In .NET Framework version 2.0, you can also use one of the following methods:
In .NET Framework 2.0, you can respond when the current tab changes by handling one of the following events:
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.
In .NET Framework 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.
The following events are not raised for the TabControl class unless there is at least one TabPage in the TabControl..::.TabPages collection: Control..::.Click, Control..::.DoubleClick, Control..::.MouseDown, Control..::.MouseUp, Control..::.MouseHover, Control..::.MouseEnter, Control..::.MouseLeave and Control..::.MouseMove. If there is at least one TabPage in the collection, and the user interacts with the tab control's header (where the TabPage names appear), the TabControl raises the appropriate event. However, if the user interaction is within the ClientRectangle of the tab page, the TabPage raises the appropriate event.
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.
When visual styles are enabled, and the Alignment property is set to a value other than Top, the tab contents might not render correctly. To work around this issue, you can paint the tab contents yourself using owner drawing. For more information, see How to: Display Side-Aligned Tabs with TabControl.
When the Alignment property is set to a value other than Top and the Appearance property is set to a value other than Normal, the tab page contents might not render correctly.