Export (0) Print
Expand All

TableLayoutPanel.SetRow Method

Sets the row position of the specified child control.

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

public void SetRow(
	Control control,
	int row
)

Parameters

control
Type: System.Windows.Forms.Control

The control to move to another row.

row
Type: System.Int32

The row to which control will be moved.

The SetRow method moves the control to another row in the TableLayoutPanel control. The columns and rows have zero-based indexes. Setting the row position to -1 specifies that the control will flow to the first empty cell.

This method reapplies the table layout to all controls in the TableLayoutPanel.

This method is called by the Row property, which the panel adds to its child controls at design time.

The following code example uses the SetColumn method to swap two controls contained within a TableLayoutPanel control. The example assumes a TableLayoutPanel control with at least two rows.

    private void swapRowsBtn_Click(
		System.Object sender, 
		System.EventArgs e)
    {

        Control c1 = this.TableLayoutPanel1.GetControlFromPosition(0, 0);
        Control c2 = this.TableLayoutPanel1.GetControlFromPosition(1, 0);

        if ( c1 !=null && c2 != null )
        {
            this.TableLayoutPanel1.SetRow(c2, 0);
            this.TableLayoutPanel1.SetRow(c1, 1);
        }
    }

.NET Framework

Supported in: 4.5.2, 4.5.1, 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.

Show:
© 2014 Microsoft