TabControl.Appearance 属性
获取或设置控件选项卡的可视外观。
**命名空间:**System.Windows.Forms
**程序集:**System.Windows.Forms(在 system.windows.forms.dll 中)
语法
声明
<LocalizableAttribute(True)> _
Public Property Appearance As TabAppearance
用法
Dim instance As TabControl
Dim value As TabAppearance
value = instance.Appearance
instance.Appearance = value
[LocalizableAttribute(true)]
public TabAppearance Appearance { get; set; }
[LocalizableAttribute(true)]
public:
property TabAppearance Appearance {
TabAppearance get ();
void set (TabAppearance value);
}
/** @property */
public TabAppearance get_Appearance ()
/** @property */
public void set_Appearance (TabAppearance value)
public function get Appearance () : TabAppearance
public function set Appearance (value : TabAppearance)
属性值
TabAppearance 值之一。默认为 Normal。
异常
异常类型 | 条件 |
---|---|
属性值不是有效的 TabAppearance 值。 |
备注
如果将 Appearance 属性设置为 FlatButtons,它仅在 Alignment 属性设置为 Top 时才那样显示。否则,Appearance 属性如同设置为 Buttons 值一样显示。
提示
将 Appearance 属性设置为 Buttons 时,还必须将 Alignment 属性设置为 Top,以使按钮正确显示。
示例
下面的代码示例创建一个包含两个 TabPage 对象的 TabControl。本示例将 Appearance 属性设置为 Buttons,它将选项卡页的选项卡以按钮形式显示。
对于此示例,使用 System.Windows.Forms 命名空间。
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
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());
}
}
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 );
}
import System.Windows.Forms.*;
public class Form1 extends 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.set_Appearance(TabAppearance.Buttons);
tabControl1.get_Controls().AddRange(new TabPage[] {tabPage1, tabPage2});
get_Controls().Add(tabControl1);
} //Form1
public static void main(String[] args)
{
Application.Run(new Form1());
} //main
} //Form1
平台
Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition
.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求。
版本信息
.NET Framework
受以下版本支持:2.0、1.1、1.0
请参见
参考
TabControl 类
TabControl 成员
System.Windows.Forms 命名空间
TabControl.Alignment 属性
TabAppearance 枚举