TableLayoutPanel.GetControlFromPosition Method (Int32, Int32)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Returns the child control occupying the specified position.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

Public Function GetControlFromPosition (
	column As Integer,
	row As Integer
) As Control


Type: System.Int32

The column position of the control to retrieve.

Type: System.Int32

The row position of the control to retrieve.

Return Value

Type: System.Windows.Forms.Control

The child control occupying the specified cell; otherwise, null if no control exists at the specified column and row, or if the control has its Visible property set to false.

Exception Condition

Either column or row (or both) is less than 0.

The column and row position values are zero based.

The following code example enumerates all the cell positions in the TableLayoutPanel by looping through the columns and rows given by ColumnCount and RowCount, and then calling the GetControlFromPosition method to retrieve the control at each cell.

Private Sub getcontrolFromPosBtn_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles getcontrolFromPosBtn.Click

    Dim i As Integer = 0
    Dim j As Integer = 0

    For i = 0 To Me.TableLayoutPanel1.ColumnCount
        For j = 0 To Me.TableLayoutPanel1.RowCount

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

            If c IsNot Nothing Then


            End If

End Sub

.NET Framework
Available since 2.0
Return to top