SizeType 枚举
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定相对于其容器应如何调整用户界面 (UI) 元素的行或列的大小。
public enum class SizeType
public enum SizeType
type SizeType =
Public Enum SizeType
- 继承
字段
| 名称 | 值 | 说明 |
|---|---|---|
| AutoSize | 0 | 行或列应自动调整大小,以便与其对等方共享空间。 |
| Absolute | 1 | 行或列的大小应为确切的像素数。 |
| Percent | 2 | 行或列的大小应为父容器的百分比。 |
示例
以下示例演示如何在对象上ColumnStyle设置TableLayoutStyle.SizeType属性。 此代码示例是为控件提供的大型示例的 TableLayoutPanel 一部分。
private void toggleColumnStylesBtn_Click(
System.Object sender,
System.EventArgs e)
{
TableLayoutColumnStyleCollection styles =
this.TableLayoutPanel1.ColumnStyles;
foreach( ColumnStyle style in styles )
{
if( style.SizeType == SizeType.Absolute )
{
style.SizeType = SizeType.AutoSize;
}
else if( style.SizeType == SizeType.AutoSize )
{
style.SizeType = SizeType.Percent;
// Set the column width to be a percentage
// of the TableLayoutPanel control's width.
style.Width = 33;
}
else
{
// Set the column width to 50 pixels.
style.SizeType = SizeType.Absolute;
style.Width = 50;
}
}
}
Private Sub toggleColumnStylesBtn_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles toggleColumnStylesBtn.Click
Dim styles As TableLayoutColumnStyleCollection = _
Me.TableLayoutPanel1.ColumnStyles
For Each style As ColumnStyle In styles
If style.SizeType = SizeType.Absolute Then
style.SizeType = SizeType.AutoSize
ElseIf style.SizeType = SizeType.AutoSize Then
style.SizeType = SizeType.Percent
' Set the column width to be a percentage
' of the TableLayoutPanel control's width.
style.Width = 33
Else
' Set the column width to 50 pixels.
style.SizeType = SizeType.Absolute
style.Width = 50
End If
Next
End Sub
注解
枚举 SizeType 指定相对于其容器大小的 UI 元素(通常控件)的行或列的大小。 此枚举由 RowStyle 类 ColumnStyle 用来指示其首选大小调整属性。 该 TableLayoutPanel 类反过来又使用这些样式类。
当为具有不同首选大小属性的行或列布局容器时,初始分配后剩余的任何空间将分布在样式为 TableLayoutStyle.SizeType “自动大小”或“百分比”属性值的行或列之间。