Export (0) Print
Expand All

TableLayoutPanel.GetControlFromPosition Method

Returns the child control occupying the specified position.

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

public Control GetControlFromPosition(
	int column,
	int row


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.


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 void getcontrolFromPosBtn_Click(
		System.Object sender, 
		System.EventArgs e)
        int i = 0;
        int j = 0;

        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 )

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft