This documentation is archived and is not being maintained.

TableLayoutPanel.GetControlFromPosition Method

Returns the child control occupying the specified position.

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

public Control GetControlFromPosition (
	int column,
	int row
public Control GetControlFromPosition (
	int column, 
	int row
public function GetControlFromPosition (
	column : int, 
	row : int
) : Control
Not applicable.



The column position of the control to retrieve.


The row position of the control to retrieve.

Return Value

The child control occupying the specified cell; otherwise, a null reference (Nothing in Visual Basic) if no control exists at the specified column and row, or if the control has its Visible property set to false.

Exception typeCondition


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 )

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0