TabControl.RowCount Property

Definition

Gets the number of rows that are currently being displayed in the control's tab strip.

C#
[System.ComponentModel.Browsable(false)]
public int RowCount { get; }

Property Value

The number of rows that are currently being displayed in the tab strip.

Attributes

Examples

The following code example creates a TabControl with five TabPage objects. This example uses the RowCount property to get the number of rows currently in the tabControl1 tab strip.

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

public class Form1 : Form
{
    public Form1()
    {
        TabControl tabControl1 = new TabControl();
        TabPage tabPage1 = new TabPage();
        TabPage tabPage2 = new TabPage();
        TabPage tabPage3 = new TabPage();
        TabPage tabPage4 = new TabPage();
        TabPage tabPage5 = new TabPage();
        Label label1= new Label();

        // Allows multiple rows of tabs in the tabControl1 tab strip.
        tabControl1.Multiline = true;

        tabControl1.SizeMode = TabSizeMode.FillToRight;
        tabControl1.Padding = new Point(15, 5);
        tabControl1.Controls.AddRange(new Control[] {
            tabPage1, tabPage2, tabPage3, tabPage4, tabPage5});
        tabControl1.Location = new Point(35, 65);
        tabControl1.Size = new Size(220, 180);    

        // Gets the number of rows currently in the tabControl1 tab strip.
        // Assigns int value to the rows variable.
        int rows = tabControl1.RowCount;

        label1.Text = "There are " + rows.ToString() + 
            " rows of tabs in the tabControl1 tab strip.";
        label1.Location = new Point(35, 25);
        label1.Size = new Size(220, 30);

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

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

Remarks

Use the RowCount property when the Multiline property is true and you want to know the number of rows that the tabs occupy.

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