TabControl::Alignment Property
Gets or sets the area of the control (for example, along the top) where the tabs are aligned.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
public: property TabAlignment Alignment { TabAlignment get(); void set(TabAlignment value); }
Property Value
Type: System.Windows.Forms::TabAlignmentOne of the TabAlignment values. The default is Top.
| Exception | Condition |
|---|---|
| InvalidEnumArgumentException | The property value is not a valid TabAlignment value. |
When the Alignment property is set to Left or Right, the Multiline property is automatically set to true.
When you set the Appearance property to FlatButtons, it only appears as such when the Alignment property is set to Top. Otherwise, the Appearance property displays as if set to the Buttons value.
When you set the Appearance property to Buttons, you must also set the Alignment property to Top so that the buttons display correctly.
Note |
|---|
When you set the Appearance property to Buttons, you must also set the Alignment property to Top so that the tab page contents display correctly. Additionally, when visual styles are enabled, and the Alignment property is set to a value other than Top, the tab contents may not render correctly. |
The following code example creates a TabControl with three TabPage objects. The Alignment property is set to Left, which positions the tabs of tabControl1 on the left side.
Use the System.Drawing and System.Windows.Forms namespaces for this example.
using namespace System::Drawing; using namespace System::Windows::Forms; public ref class Form1: public Form { private: TabControl^ tabControl1; TabPage^ tabPage1; TabPage^ tabPage2; TabPage^ tabPage3; void MyTabs() { this->tabControl1 = gcnew TabControl; this->tabPage1 = gcnew TabPage; this->tabPage2 = gcnew TabPage; this->tabPage3 = gcnew TabPage; // Positions tabs on the left side of tabControl1. this->tabControl1->Alignment = System::Windows::Forms::TabAlignment::Left; array<Control^>^tabControls = {this->tabPage1,this->tabPage2,this->tabPage3}; this->tabControl1->Controls->AddRange( tabControls ); this->tabControl1->Location = Point(16,24); this->tabControl1->SelectedIndex = 0; this->tabControl1->Size = System::Drawing::Size( 248, 232 ); this->tabControl1->TabIndex = 0; this->tabPage1->TabIndex = 0; this->tabPage2->TabIndex = 1; this->tabPage3->TabIndex = 2; this->Size = System::Drawing::Size( 300, 300 ); array<Control^>^formControls = {this->tabControl1}; this->Controls->AddRange( formControls ); } public: Form1() { MyTabs(); } }; int main() { Application::Run( gcnew Form1 ); }
Available since 1.1
