SizeType 列舉

定義

指定使用者介面 (UI) 項目的資料列或資料行應該要如何根據與其容器之間的相對關係來調整大小。

public enum class SizeType
public enum SizeType
type SizeType = 
Public Enum SizeType
繼承
SizeType

欄位

Absolute 1

資料列或資料行應該調整大小成為精確的像素數。

AutoSize 0

資料列或資料行應該自動調整大小,與其對等項目共用空間。

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 元素的資料列或資料行通常應該相對於容器的大小來調整大小。 和 ColumnStyle 類別會使用此列舉來指出其慣用 RowStyle 的大小調整屬性。 類別 TableLayoutPanel 接著會使用這些樣式類別。

配置具有不同慣用調整大小屬性之資料列或資料行的容器時,初始配置之後剩餘的任何空間都會分散在樣式為 TableLayoutStyle.SizeType AutoSize 或 Percent 屬性值的資料列或資料行之間。

適用於

另請參閱