TabControl.SizeMode Property

Definition

Gets or sets the way that the control's tabs are sized.

C#
public System.Windows.Forms.TabSizeMode SizeMode { get; set; }

Property Value

One of the TabSizeMode values. The default is Normal.

Exceptions

The property value is not a valid TabSizeMode value.

Examples

The following code example creates a TabControl with five TabPage. This example sets the SizeMode property to FillToRight, which sizes the tabs so that each row fills the entire width of tabControl1.

C#
using System.Drawing;
using System.Windows.Forms;

public class Form1 : Form
{
    private TabControl tabControl1;

    public Form1()
    {
        this.tabControl1 = new TabControl();
        TabPage tabPage1 = new TabPage();
        TabPage tabPage2 = new TabPage();
        TabPage tabPage3 = new TabPage();
        TabPage tabPage4 = new TabPage();
        TabPage tabPage5 = new TabPage();

        TabPage[] tabPages = {tabPage1, tabPage2, tabPage3, tabPage4, tabPage5};
        
        // Sizes the tabs so that each row fills the entire width of tabControl1.
        this.tabControl1.SizeMode = TabSizeMode.FillToRight;

        this.tabControl1.Multiline = true;
        this.tabControl1.Padding = new Point(15, 5);
        this.tabControl1.Controls.AddRange(new Control[] {
            tabPage1, tabPage2, tabPage3, tabPage4, tabPage5});
        this.tabControl1.Location = new Point(35, 25);
        this.tabControl1.Size = new Size(220, 220);    

        this.Size = new Size(300, 300);
        this.Controls.Add(tabControl1);
    }

    static void Main() 
    {
        Application.Run(new Form1());
    }
}

Applies to

Product Versions
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also