TabControl.Appearance 屬性

定義

取得或設定控制項索引標籤的視覺外觀。

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

屬性值

其中一個 TabAppearance 值。 預設值為 Normal

例外狀況

屬性值不是有效的 TabAppearance 值。

範例

下列程式碼範例會建立具有兩 TabPageTabControl 物件的 。 本範例會將 Appearance 屬性設定為 Buttons ,其會將索引標籤頁面的索引標籤顯示為按鈕。

using namespace System;
using namespace System::Windows::Forms;
public ref class Form1: public Form
{
public:
   Form1()
   {
      array<String^>^tabText = {"tabPage1","tabPage2"};
      TabControl^ tabControl1 = gcnew TabControl;
      TabPage^ tabPage1 = gcnew TabPage( tabText[ 0 ] );
      TabPage^ tabPage2 = gcnew TabPage( tabText[ 1 ] );
      
      // Sets the tabs to appear as buttons.
      tabControl1->Appearance = TabAppearance::Buttons;
      array<TabPage^>^tabPageArray = {tabPage1,tabPage2};
      tabControl1->Controls->AddRange( tabPageArray );
      Controls->Add( tabControl1 );
   }

};

int main()
{
   Application::Run( gcnew Form1 );
}
using System.Windows.Forms;

public class Form1 : Form
{
    public Form1()
    {
        string[] tabText = {"tabPage1", "tabPage2"};
        TabControl tabControl1 = new TabControl();
        TabPage tabPage1 = new TabPage(tabText[0]);
        TabPage tabPage2 = new TabPage(tabText[1]);

        // Sets the tabs to appear as buttons.
        tabControl1.Appearance = TabAppearance.Buttons;

        tabControl1.Controls.AddRange(new TabPage[] {tabPage1, tabPage2});
        Controls.Add(tabControl1);
    }

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

Public Class Form1
    Inherits Form

    Public Sub New()
        Dim tabText As String() = {"tabPage1", "tabPage2"}
        Dim tabControl1 As New TabControl()
        Dim tabPage1 As New TabPage(tabText(0))
        Dim tabPage2 As New TabPage(tabText(1))

        ' Sets the tabs to appear as buttons.
        tabControl1.Appearance = TabAppearance.Buttons

        tabControl1.Controls.AddRange(New TabPage() {tabPage1, tabPage2})
        Controls.Add(tabControl1)
    End Sub

    Shared Sub Main()
        Application.Run(New Form1())
    End Sub
End Class

備註

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

注意

當您將 Appearance 屬性設定為 Buttons 時,也必須將 屬性設定 AlignmentTop ,讓索引標籤頁面內容正確顯示。

適用於

另請參閱