TableLayoutPanel.GrowStyle 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值, TableLayoutPanel 该值指示控件是否应在占用所有现有单元格时展开以容纳新单元格。
public:
property System::Windows::Forms::TableLayoutPanelGrowStyle GrowStyle { System::Windows::Forms::TableLayoutPanelGrowStyle get(); void set(System::Windows::Forms::TableLayoutPanelGrowStyle value); };
public System.Windows.Forms.TableLayoutPanelGrowStyle GrowStyle { get; set; }
member this.GrowStyle : System.Windows.Forms.TableLayoutPanelGrowStyle with get, set
Public Property GrowStyle As TableLayoutPanelGrowStyle
属性值
指示 TableLayoutPanelGrowStyle 增长方案。 默认值为 AddRows。
例外
该属性值对 TableLayoutPanelGrowStyle 枚举无效。
示例
下面的代码示例根据所选RadioButton属性GrowStyle设置属性的值。 在运行时,当用户单击标记为 Test GrowStyle 的按钮时, Button 控件将添加到控件 TableLayoutPanel 。 TableLayoutPanel如果控件已满,则通过添加行或列进行扩展,或者根据值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);
}
}
Private Sub growStyleNoneBtn_CheckedChanged( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles growStyleNoneBtn.CheckedChanged
Me.tlpGrowStyle = TableLayoutPanelGrowStyle.FixedSize
End Sub
Private Sub growStyleAddRowBtn_CheckedChanged( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles growStyleAddRowBtn.CheckedChanged
Me.tlpGrowStyle = TableLayoutPanelGrowStyle.AddRows
End Sub
Private Sub growStyleAddColumnBtn_CheckedChanged( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles growStyleAddColumnBtn.CheckedChanged
Me.tlpGrowStyle = TableLayoutPanelGrowStyle.AddColumns
End Sub
Private Sub testGrowStyleBtn_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles testGrowStyleBtn.Click
Me.TableLayoutPanel1.GrowStyle = Me.tlpGrowStyle
Try
Me.TableLayoutPanel1.Controls.Add(New Button())
Catch ex As ArgumentException
Trace.WriteLine(ex.Message)
End Try
End Sub
注解
默认情况下,控件 TableLayoutPanel 通过添加行向下展开。
注释
如果尝试将控件添加到完全 TableLayoutPanel 控件,并且值为 GrowStyleFixedSize,则会引发一个 ArgumentException 。