ColumnStyle 類別

定義

表示資料表配置中的資料行之外觀及操作。

public ref class ColumnStyle : System::Windows::Forms::TableLayoutStyle
public class ColumnStyle : System.Windows.Forms.TableLayoutStyle
type ColumnStyle = class
    inherit TableLayoutStyle
Public Class ColumnStyle
Inherits TableLayoutStyle
繼承
ColumnStyle

範例

下列程式碼範例示範如何從 擷 TableLayoutColumnStyleCollectionColumnStyle

此程式碼範例是針對 類別提供的較大範例的 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

備註

類別 ColumnStyle 代表 中資料行 TableLayoutPanel 的使用者介面 (UI) 特性。 這類資料表中所有資料行的樣式都會收集在 屬性中 TableLayoutPanel.ColumnStyles

這個簡單類別提供資料行的 WidthSizeType 屬性。

建構函式

ColumnStyle()

ColumnStyle 類別的新執行個體初始化為預設狀態。

ColumnStyle(SizeType)

使用提供的 SizeType 值來將 ColumnStyle 類別的新執行個體初始化。

ColumnStyle(SizeType, Single)

使用提供的 ColumnStyle 和寬度值,將 SizeType 類別的執行個體初始化。

屬性

SizeType

取得或設定旗標,表示資料列或資料行應該要如何調整大小 (相對於其包含資料表)。

(繼承來源 TableLayoutStyle)
Width

取得或設定資料行的寬度值。

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

另請參閱