共用方式為


TabControl.Alignment 屬性

定義

取得或設定索引標籤所對齊的控制項區域 (例如,沿著上方)。

public:
 property System::Windows::Forms::TabAlignment Alignment { System::Windows::Forms::TabAlignment get(); void set(System::Windows::Forms::TabAlignment value); };
public System.Windows.Forms.TabAlignment Alignment { get; set; }
member this.Alignment : System.Windows.Forms.TabAlignment with get, set
Public Property Alignment As TabAlignment

屬性值

TabAlignment

其中一個 TabAlignment 值。 預設為 Top

例外狀況

屬性值不是有效的 TabAlignment 值。

範例

下列程式碼範例會建立具有三 TabPageTabControl 物件的 。 屬性 Alignment 設定為 Left ,它會將 的索引標籤 tabControl1 置於左側。

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 );
}
using System.Drawing;
using System.Windows.Forms;

public class Form1 : Form
{
    private TabControl tabControl1;
    private TabPage tabPage1;
    private TabPage tabPage2;
    private TabPage tabPage3;

    private void MyTabs()
    {
        this.tabControl1 = new TabControl();
        this.tabPage1 = new TabPage();
        this.tabPage2 = new TabPage();
        this.tabPage3 = new TabPage();

        // Positions tabs on the left side of tabControl1.
        this.tabControl1.Alignment = System.Windows.Forms.TabAlignment.Left;

        this.tabControl1.Controls.AddRange(new Control[] {
            this.tabPage1,
            this.tabPage2,
            this.tabPage3});
        this.tabControl1.Location = new Point(16, 24);
        this.tabControl1.SelectedIndex = 0;
        this.tabControl1.Size = new Size(248, 232);
        this.tabControl1.TabIndex = 0;

        this.tabPage1.TabIndex = 0;
        this.tabPage2.TabIndex = 1;
        this.tabPage3.TabIndex = 2;

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

    public Form1()
    {
        MyTabs();
    }

    static void Main() 
    {
        Application.Run(new Form1());
    }
}
Imports System.Drawing
Imports System.Windows.Forms

Public Class Form1
    Inherits Form
    Private tabControl1 As TabControl
    Private tabPage1 As TabPage
    Private tabPage2 As TabPage
    Private tabPage3 As TabPage

    Private Sub MyTabs()
        Me.tabControl1 = New TabControl()
        Me.tabPage1 = New TabPage()
        Me.tabPage2 = New TabPage()
        Me.tabPage3 = New TabPage()

        ' Positions tabs on the left side of tabControl1.
        Me.tabControl1.Alignment = System.Windows.Forms.TabAlignment.Left

        Me.tabControl1.Controls.AddRange(New Control() {Me.tabPage1, Me.tabPage2, Me.tabPage3})
        Me.tabControl1.Location = New Point(16, 24)
        Me.tabControl1.SelectedIndex = 0
        Me.tabControl1.Size = New Size(248, 232)
        Me.tabControl1.TabIndex = 0

        Me.tabPage1.TabIndex = 0
        Me.tabPage2.TabIndex = 1
        Me.tabPage3.TabIndex = 2

        Me.Size = 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

備註

當 屬性 Alignment 設定為 LeftRight 時, Multiline 屬性會自動設定為 true

當您將 Appearance 屬性設定為 FlatButtons 時,它只會在 屬性設定為 TopAlignment 顯示。 否則, Appearance 屬性會顯示為設定為 Buttons 值。

當您將 Appearance 屬性設定為 Buttons 時,也必須將 屬性設定 AlignmentTop ,讓按鈕正確顯示。

注意

當您將 Appearance 屬性設定為 Buttons 時,也必須將 屬性設定 AlignmentTop ,讓索引標籤頁面內容正確顯示。 此外,啟用視覺樣式,而且 Alignment 屬性設定為 以外的 Top 值時,索引標籤內容可能無法正確轉譯。

適用於

另請參閱