편집

다음을 통해 공유


TableLayoutControlCollection.Add(Control, Int32, Int32) Method

Definition

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

public:
 virtual void Add(System::Windows::Forms::Control ^ control, int column, int row);
public virtual void Add (System.Windows.Forms.Control control, int column, int row);
override this.Add : System.Windows.Forms.Control * int * int -> unit
Public Overridable Sub Add (control As Control, column As Integer, row As Integer)

Parameters

control
Control

The control to add.

column
Int32

The column in which control will be placed.

row
Int32

The row in which control will be placed.

Exceptions

Either column or row is less than -1.

Remarks

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.

Applies to

See also