TableLayoutPanel.SetColumn(Control, Int32) 메서드

정의

지정된 자식 컨트롤의 열 위치를 설정합니다.

public:
 void SetColumn(System::Windows::Forms::Control ^ control, int column);
public void SetColumn(System.Windows.Forms.Control control, int column);
member this.SetColumn : System.Windows.Forms.Control * int -> unit
Public Sub SetColumn (control As Control, column As Integer)

매개 변수

control
Control

다른 열로 이동할 컨트롤입니다.

column
Int32

이동할 열 control 입니다.

예제

다음 코드 예제에서는 메서드를 SetColumn 사용 하 여 컨트롤 내에 포함 된 두 개의 컨트롤을 교환 합니다 TableLayoutPanel . 이 예제에서는 행이 두 개 이상 있는 TableLayoutPanel 컨트롤을 가정합니다.

private void swapControlsBtn_Click(
    System.Object sender, 
    System.EventArgs e)
{
    Control c1 = this.TableLayoutPanel1.GetControlFromPosition(0, 0);
    Control c2 = this.TableLayoutPanel1.GetControlFromPosition(0, 1);

    if( c1 != null && c2 != null )
    {
        this.TableLayoutPanel1.SetColumn(c2, 0);
        this.TableLayoutPanel1.SetColumn(c1, 1);
    }
}
Private Sub swapControlsBtn_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles swapControlsBtn.Click

    Dim c1 As Control = Me.TableLayoutPanel1.GetControlFromPosition(0, 0)
    Dim c2 As Control = Me.TableLayoutPanel1.GetControlFromPosition(0, 1)

    If c1 IsNot Nothing And c2 IsNot Nothing Then

        Me.TableLayoutPanel1.SetColumn(c2, 0)
        Me.TableLayoutPanel1.SetColumn(c1, 1)

    End If

End Sub

설명

메서드는 SetColumn 컨트롤을 .의 다른 열로 TableLayoutPanel이동합니다. 열과 행에는 0부터 시작하는 인덱스가 있습니다. 열 위치를 -1 설정하면 컨트롤이 첫 번째 빈 셀로 이동하도록 지정합니다.

이 메서드는 테이블 레이아웃을 .의 모든 컨트롤에 TableLayoutPanel다시 적용합니다.

이 메서드는 디자인 타임에 패널이 Column 자식 컨트롤에 추가하는 속성에 의해 호출됩니다.

적용 대상

추가 정보