Export (0) Print
Expand All

TableLayoutPanel.GrowStyle Property

Note: This property is new in the .NET Framework version 2.0.

Gets or sets a value indicating whether the TableLayoutPanel control should expand to accommodate new cells when all existing cells are occupied.

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

public TableLayoutPanelGrowStyle GrowStyle { get; set; }
/** @property */
public TableLayoutPanelGrowStyle get_GrowStyle ()

/** @property */
public void set_GrowStyle (TableLayoutPanelGrowStyle value)

public function get GrowStyle () : TableLayoutPanelGrowStyle

public function set GrowStyle (value : TableLayoutPanelGrowStyle)

Property Value

A TableLayoutPanelGrowStyle indicating the growth scheme. The default is AddRows.

Exception typeCondition

ArgumentException

The property value is invalid for the TableLayoutPanelGrowStyle enumeration.

By default, the TableLayoutPanel control expands downward by adding rows.

NoteNote

If an attempt is made to add a control to a full TableLayoutPanel control, and the value of GrowStyle is FixedSize, then an ArgumentException is thrown.

The following code example sets the value of the GrowStyle property depending on the selected RadioButton. At run time, when the user clicks on the button labeled Test GrowStyle, a Button control is added to the TableLayoutPanel control. If the TableLayoutPanel control is full, it expands by adding a row or column, or it raises an exception, depending on the value of GrowStyle.

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

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

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

.NET Framework

Supported in: 2.0

Community Additions

ADD
Show:
© 2014 Microsoft