This documentation is archived and is not being maintained.

TableLayoutPanel.RowStyles Property

Gets a collection of row styles for the TableLayoutPanel.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public TableLayoutRowStyleCollection RowStyles { get; }

Use the RowStyles property to access the style properties of specific rows. You can use members of the RowStyle class to set the characteristics of individual rows in the table.

When the TableLayoutPanel control arranges its rows, it assigns priorities to each RowStyle in the following order:

  1. Rows with RowStyle set to Absolute are considered first, and their fixed heights are allocated.

  2. Rows with RowStyle set to AutoSize are sized to their contents.

  3. Remaining space is divided among rows with RowStyle set to Percent.

The following code example sets the RowStyle properties of each row when a Button is clicked.

    private void toggleRowStylesBtn_Click(
		System.Object sender, 
		System.EventArgs e)
		TableLayoutRowStyleCollection styles = 

        foreach( RowStyle style in styles )
            if (style.SizeType==SizeType.Absolute)
                style.SizeType = SizeType.AutoSize;
            else if(style.SizeType==SizeType.AutoSize)
                style.SizeType = SizeType.Percent;

                // Set the row height to be a percentage
                // of the TableLayoutPanel control's height.
                style.Height = 33;

                // Set the row height to 50 pixels.
                style.SizeType = SizeType.Absolute;
                style.Height = 50;

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.