TableLayoutPanel.GetColumn(Control) 메서드

정의

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

public:
 int GetColumn(System::Windows::Forms::Control ^ control);
public int GetColumn (System.Windows.Forms.Control control);
member this.GetColumn : System.Windows.Forms.Control -> int
Public Function GetColumn (control As Control) As Integer

매개 변수

control
Control

TableLayoutPanel의 자식 컨트롤입니다.

반환

Int32

지정된 자식 컨트롤의 열 위치이거나, control의 위치가 LayoutEngine에 의해 결정되는 경우 -1입니다.

예외

control이(가) null인 경우

control이 이 LayoutEngine에서 정렬할 수 있는 형식이 아닌 경우

예제

다음 코드 예제에서는 모든 자식 컨트롤을 열거 하 고 메서드를 TableLayoutPanel 사용 하 여 GetColumn 각 컨트롤에 대 한 열 인덱스를 찾습니다.

private void getColumnBtn_Click(
    System.Object sender, 
    System.EventArgs e)
{
    foreach ( Control c in this.TableLayoutPanel1.Controls )
    {
        Trace.WriteLine(this.TableLayoutPanel1.GetColumn(c));
    }
}
Private Sub getColumnBtn_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles getColumnBtn.Click

    Dim c As Control
    For Each c In Me.TableLayoutPanel1.Controls

        Trace.WriteLine(Me.TableLayoutPanel1.GetColumn(c))

    Next

End Sub

설명

두 개 이상의 열에 걸쳐 있는 경우 control 메서드는 GetColumn 가장 낮은 열 인덱스를 반환합니다.

열 위치 값은 0부터 사용하므로 반환된 GetColumnWidths배열에 대한 인덱스로 사용할 수 있습니다.

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

위치가 결정LayoutEngine된 경우에도 실제 위치를 control얻으려면 메서드를 호출합니다GetPositionFromControl.

적용 대상

추가 정보