Edit

Share via


TableLayoutPanelGrowStyle Enum

Definition

Specifies how a TableLayoutPanel will gain additional rows or columns after its existing cells are full.

C#
public enum TableLayoutPanelGrowStyle
Inheritance
TableLayoutPanelGrowStyle

Fields

Name Value Description
FixedSize 0

The TableLayoutPanel does not allow additional rows or columns after it is full.

AddRows 1

The TableLayoutPanel gains additional rows after it is full.

AddColumns 2

The TableLayoutPanel gains additional columns after it is full.

Examples

The following example shows how to use TableLayoutPanelGrowStyle to set the TableLayoutPanel.GrowStyle property. This example is part of a larger example provided for the TableLayoutPanel control.

C#
private void growStyleNoneBtn_CheckedChanged(
    System.Object sender, 
    System.EventArgs e)
{
    this.tlpGrowStyle = TableLayoutPanelGrowStyle.FixedSize;
}

private void growStyleAddRowBtn_CheckedChanged(
    System.Object sender, 
    System.EventArgs e)
{
    this.tlpGrowStyle = TableLayoutPanelGrowStyle.AddRows;
}

private void growStyleAddColumnBtn_CheckedChanged(
    System.Object sender, 
    System.EventArgs e)
{
    this.tlpGrowStyle = TableLayoutPanelGrowStyle.AddColumns;
}

private void testGrowStyleBtn_Click(
    System.Object sender, 
    System.EventArgs e)
{
    this.TableLayoutPanel1.GrowStyle = this.tlpGrowStyle;

    try
    {
        this.TableLayoutPanel1.Controls.Add(new Button());
    }
    catch(ArgumentException ex)
    {
        Trace.WriteLine(ex.Message);
    }
}

Remarks

If all the cells in the TableLayoutPanel are filled and the GrowStyle property is set to FixedSize, an attempt to add another control will throw an exception.

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

See also