RowCount Property

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)

[BrowsableAttribute(false)]
public int RowCount { get; }

Property Value

Type: System.Int32

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

.NET Framework
Available since 1.1
Return to top
Show:
© 2016 Microsoft