title | ms.date | dev_langs | helpviewer_keywords | ms.assetid | description | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Change the Appearance of TabControl |
03/30/2017 |
|
|
7c6cc443-ed62-4d26-b94d-b8913b44f773 |
Learn how to change the appearance of the Windows Forms tabs by using the properties of the TabControl and the TabPage objects. |
You can change the appearance of tabs in Windows Forms by using properties of the xref:System.Windows.Forms.TabControl and the xref:System.Windows.Forms.TabPage objects that make up the individual tabs on the control. By setting these properties, you can display images on tabs, display tabs vertically instead of horizontally, display multiple rows of tabs, and enable or disable tabs programmatically.
-
Add an xref:System.Windows.Forms.ImageList control to the form.
-
Add images to the image list.
For more information about image lists, see ImageList Component and How to: Add or Remove Images with the Windows Forms ImageList Component.
-
Set the xref:System.Windows.Forms.TabControl.ImageList%2A property of the xref:System.Windows.Forms.TabControl to the xref:System.Windows.Forms.ImageList control.
-
Set the xref:System.Windows.Forms.TabPage.ImageIndex%2A property of the xref:System.Windows.Forms.TabPage to the index of an appropriate image in the list.
-
Add the number of tab pages you want.
-
Set the xref:System.Windows.Forms.TabControl.Multiline%2A property of the xref:System.Windows.Forms.TabControl to
true
. -
If the tabs do not already appear in multiple rows, set the xref:System.Windows.Forms.Control.Width%2A property of the xref:System.Windows.Forms.TabControl to be narrower than all the tabs.
- Set the xref:System.Windows.Forms.TabControl.Alignment%2A property of the xref:System.Windows.Forms.TabControl to xref:System.Windows.Forms.TabAlignment.Left or xref:System.Windows.Forms.TabAlignment.Right.
-
Set the xref:System.Windows.Forms.TabPage.Enabled%2A property of the xref:System.Windows.Forms.TabPage to
true
orfalse
.TabPage1.Enabled = False
tabPage1.Enabled = false;
tabPage1->Enabled = false;
- Set the xref:System.Windows.Forms.TabControl.Appearance%2A property of the xref:System.Windows.Forms.TabControl to xref:System.Windows.Forms.TabAppearance.Buttons or xref:System.Windows.Forms.TabAppearance.FlatButtons.