TableLayoutPanel.RowStyles Property

Definition

Gets a collection of row styles for the TableLayoutPanel.

C#
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.TableLayoutRowStyleCollection RowStyles { get; }

Property Value

A TableLayoutRowStyleCollection containing a RowStyle for each row in the TableLayoutPanel control.

Attributes

Examples

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

C#
private void toggleRowStylesBtn_Click(
    System.Object sender, 
    System.EventArgs e)
{
    TableLayoutRowStyleCollection styles = 
        this.TableLayoutPanel1.RowStyles;

    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;
        }
        else
        {

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

Remarks

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.

Applies to

Product Versions
.NET Framework 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