TableLayoutPanel.GetControlFromPosition(Int32, Int32) 메서드

정의

지정된 위치에 있는 자식 컨트롤을 반환합니다.

public:
 System::Windows::Forms::Control ^ GetControlFromPosition(int column, int row);
public System.Windows.Forms.Control GetControlFromPosition (int column, int row);
public System.Windows.Forms.Control? GetControlFromPosition (int column, int row);
member this.GetControlFromPosition : int * int -> System.Windows.Forms.Control
Public Function GetControlFromPosition (column As Integer, row As Integer) As Control

매개 변수

column
Int32

검색할 컨트롤의 열 위치입니다.

row
Int32

검색할 컨트롤의 행 위치입니다.

반환

지정된 셀에 있는 자식 컨트롤입니다. 지정된 열과 행에 컨트롤이 없거나 컨트롤의 Visible 속성이 null로 설정된 경우에는 false입니다.

예외

column 또는 row가 0보다 작은 경우

예제

다음 코드 예제에서는 열거 하 여 의 모든 셀 위치를 TableLayoutPanel 열거 하 여 열거 하 고 열거 하는 열거 하는 열거 및 열거 열거 하는 열 ColumnCountRowCount거 하 고 각 셀에서 컨트롤을 검색 하는 메서드를 호출 GetControlFromPosition 합니다.

private void getcontrolFromPosBtn_Click(
    System.Object sender, 
    System.EventArgs e)
{
    int i = 0;
    int j = 0;
    Trace.WriteLine(this.TableLayoutPanel1.ColumnCount);
    Trace.WriteLine(this.TableLayoutPanel1.RowCount);

    for(i=0; i<=this.TableLayoutPanel1.ColumnCount; i++)
    {
        for(j=0; j<=this.TableLayoutPanel1.RowCount; j++)
        {
            Control c = this.TableLayoutPanel1.GetControlFromPosition(i, j);

            if( c != null )
            {
                Trace.WriteLine(c.ToString());
            }
        }
    }
}
Private Sub getcontrolFromPosBtn_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles getcontrolFromPosBtn.Click


    Trace.WriteLine(Me.TableLayoutPanel1.ColumnCount)
    Trace.WriteLine(Me.TableLayoutPanel1.RowCount)

    For i As Integer = 0 To Me.TableLayoutPanel1.ColumnCount - 1
        For j As Integer = 0 To Me.TableLayoutPanel1.RowCount - 1

            Dim c As Control = Me.TableLayoutPanel1.GetControlFromPosition(i, j)

            If c IsNot Nothing Then

                Trace.WriteLine(c.ToString())

            End If
        Next
    Next

End Sub

설명

열 및 행 위치 값은 0부터 시작합니다.

적용 대상

추가 정보