TableLayoutPanel.GrowStyle Propiedad

Definición

Obtiene o establece un valor que indica si el control TableLayoutPanel debe expandirse para alojar las nuevas celdas cuando todas las celdas existentes están ocupadas.

C#
public System.Windows.Forms.TableLayoutPanelGrowStyle GrowStyle { get; set; }

Valor de propiedad

TableLayoutPanelGrowStyle que indica el esquema de crecimiento. De manera predeterminada, es AddRows.

Excepciones

El valor de propiedad es no válido para la enumeración TableLayoutPanelGrowStyle.

Ejemplos

En el ejemplo de código siguiente se establece el valor de la GrowStyle propiedad según el seleccionado RadioButton. En tiempo de ejecución, cuando el usuario hace clic en el botón con la etiqueta Test GrowStyle, se agrega un Button control al TableLayoutPanel control . Si el TableLayoutPanel control está lleno, se expande agregando una fila o columna, o genera una excepción, según el valor de GrowStyle.

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

Comentarios

De forma predeterminada, el control TableLayoutPanel se expande hacia abajo agregando filas.

Nota

Si se intenta agregar un control a un control total TableLayoutPanel y el valor de GrowStyle es FixedSize, se produce una ArgumentException excepción .

Se aplica a

Produto Versións
.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

Consulte también