TableLayoutControlCollection.Add(Control, Int32, Int32) 方法

定义

将指定的控件添加到集合中,并将其置于指定单元格的位置。

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)

参数

control
Control

要添加的控件。

column
Int32

要放置的 control 列。

row
Int32

要放置的 control 行。

例外

要么columnrow小于 -1。

注解

使用 Add,可以指定单元格 control位置。 可以通过提供control和参数来分配column特定单元格,也可以仅指定列或行值,并允许在下row一个打开的单元格中放置位置LayoutEnginecontrol。 这称为让控制 向控件中 TableLayoutPanel 的位置。

如果要column占用固定行位置,请设置为 control -1。

如果要row占用固定列位置,请设置为 control -1。

如果两者 column 都不 row 加 -1, control 将添加到 (columnrow) 的绝对位置。

如果同时 column 设置和 row 设置为 -1, control 则会流向第一个打开位置,并具有由值定义的 TableLayoutPanel.GrowStyle 特定流行为。 这等效于使用 Control.ControlCollection.Add 该方法。

若要访问控件的实际当前位置,请使用 TableLayoutPanel.GetPositionFromControl 该方法。 此方法将考虑整个TableLayoutPanel控件状态,包括列或行跨越,以及放置控件及其TableLayoutPanel.LayoutEngineColumn属性设置为 -1 的时间Row

适用于

另请参阅