TableLayoutPanel.SetRow(Control, Int32) 메서드

정의

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

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

매개 변수

control
Control

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

row
Int32

이동할 행 control 입니다.

예제

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

private void swapRowsBtn_Click(
    System.Object sender, 
    System.EventArgs e)
{

    Control c1 = this.TableLayoutPanel1.GetControlFromPosition(0, 0);
    Control c2 = this.TableLayoutPanel1.GetControlFromPosition(1, 0);

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

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

    If c1 IsNot Nothing And c2 IsNot Nothing Then

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

    End If


End Sub

설명

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

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

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

적용 대상

추가 정보