Export (0) Print
Expand All

TableLayoutControlCollection.Add Method (Control, Int32, Int32)

Adds the specified control to the collection and positions it at the specified cell.

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

public virtual void Add(
	Control control,
	int column,
	int row
)

Parameters

control
Type: System.Windows.Forms.Control

The control to add.

column
Type: System.Int32

The column in which control will be placed.

row
Type: System.Int32

The row in which control will be placed.

ExceptionCondition
ArgumentException

Either column or row is less than -1.

With Add, you can specify the cell position of control. You can assign control to a specific cell by providing both the column and row parameters, or you can specify only the column or row value and let the LayoutEngine place control at the next open cell. This is known as letting the control flow to its position in the TableLayoutPanel control.

Set column to -1 if you want control to occupy a fixed row position.

Set row to -1 if you want control to occupy a fixed column position.

If neither column nor row is -1, control will be added at the absolute position given by (column, row).

If you set both column and row to -1, control will flow to the first open position, with the specific flow behavior defined by the TableLayoutPanel.GrowStyle value. This is equivalent to using the Control.ControlCollection.Add method.

To get to the actual current position of a control, use the TableLayoutPanel.GetPositionFromControl method. This method takes into account the entire TableLayoutPanel control state, including column or row spanning and when the TableLayoutPanel.LayoutEngine has placed a control with its Column and Row properties set to -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