TableLayoutPanelGrowStyle 枚举

定义

指定 TableLayoutPanel 在其现有单元格已满之后,如何获取其他行或列。

C#
public enum TableLayoutPanelGrowStyle
继承
TableLayoutPanelGrowStyle

字段

名称 说明
AddColumns 2

TableLayoutPanel 在已满之后将获取其他列。

AddRows 1

TableLayoutPanel 在已满之后将获取其他行。

FixedSize 0

TableLayoutPanel 在已满之后不允许获取其他行或列。

示例

以下示例演示如何使用 TableLayoutPanelGrowStyle 设置 TableLayoutPanel.GrowStyle 属性。 此示例是为 控件提供的更大示例的 TableLayoutPanel 一部分。

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

注解

如果 中的所有单元格 TableLayoutPanel 都已填充,并且 属性 GrowStyle 设置为 FixedSize,则尝试添加另一个控件将引发异常。

适用于

产品 版本
.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

另请参阅