TableLayoutPanel.ColumnStyles 속성

정의

TableLayoutPanel에 대한 열 스타일의 컬렉션을 가져옵니다.

public:
 property System::Windows::Forms::TableLayoutColumnStyleCollection ^ ColumnStyles { System::Windows::Forms::TableLayoutColumnStyleCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.TableLayoutColumnStyleCollection ColumnStyles { get; }
[<System.ComponentModel.Browsable(false)>]
member this.ColumnStyles : System.Windows.Forms.TableLayoutColumnStyleCollection
Public ReadOnly Property ColumnStyles As TableLayoutColumnStyleCollection

속성 값

TableLayoutColumnStyleCollection

TableLayoutColumnStyleCollection 컨트롤의 각 열에 대한 ColumnStyle을 포함하는 TableLayoutPanel입니다.

특성

예제

다음 코드 예제에서는 클릭할 ColumnStyleButton 각 열의 속성을 설정합니다.

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

설명

ColumnStyles 속성을 사용하여 특정 열의 스타일 속성에 액세스합니다. 클래스의 멤버를 ColumnStyle 사용하여 테이블에서 개별 열의 특성을 설정할 수 있습니다.

컨트롤이 TableLayoutPanel 해당 열을 정렬할 때 다음 순서로 각각 ColumnStyle 에 우선 순위를 할당합니다.

  1. ColumnStyle 설정된 Absolute 열이 먼저 고려되고 고정 너비가 할당됩니다.

  2. 설정이 ColumnStyle 설정된 AutoSize 열은 해당 내용에 맞게 크기가 조정됩니다.

  3. 나머지 공간은 으로 설정된 Percent열로 ColumnStyle 나뉩니다.

적용 대상

추가 정보