This documentation is archived and is not being maintained.

TabControl.RowCount Property

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

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

public int RowCount { get; }
/** @property */
public int get_RowCount ()

public function get RowCount () : int

Not applicable.

Property Value

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

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

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.

Use the System.Drawing and System.Windows.Forms namespaces for this example.

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());
    }
}

import System.Drawing.*;
import System.Windows.Forms.*;

public class Form1 extends 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.set_Multiline(true);
        tabControl1.set_SizeMode(TabSizeMode.FillToRight);
        tabControl1.set_Padding(new Point(15, 5));
        tabControl1.get_Controls().AddRange(new Control[] { tabPage1, tabPage2,
            tabPage3, tabPage4, tabPage5 });
        tabControl1.set_Location(new Point(35, 65));
        tabControl1.set_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.get_RowCount();

        label1.set_Text("There are " + ((System.Int32)rows).ToString() 
            + " rows of tabs in the tabControl1 tab strip.");
        label1.set_Location(new Point(35, 25));
        label1.set_Size(new Size(220, 30));
        set_Size(new Size(300, 300));
        get_Controls().AddRange(new Control[] {label1, tabControl1 });
    } //Form1

    public static void main(String[] args)
    {
        Application.Run(new Form1());
    } //main
} //Form1

Windows 98, Windows Server 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

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0
Show: