共用方式為


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 格位置。 您可以同時提供 columnrow 參數,或只指定資料行或資料列值,並讓 LayoutEngine 下一個開啟儲存格的位置 control 指派給 control 特定儲存格。 這稱為讓控制 流程 流向控制項中 TableLayoutPanel 的位置。

如果您想要 control 佔用固定資料列位置,請將 設定 column 為 -1。

如果您想要 control 佔用固定資料行位置,請將 設定 row 為 -1。

如果 和 column row 都不是 -1, control 則會新增至 (column row 指定的絕對位置,) 。

如果您同時 column 將 和 row 設定為 -1, control 將會流向第一個開啟位置,並具有值所 TableLayoutPanel.GrowStyle 定義的特定流程行為。 這相當於使用 Control.ControlCollection.Add 方法。

若要取得控制項的實際目前位置,請使用 TableLayoutPanel.GetPositionFromControl 方法。 這個方法會將整個 TableLayoutPanel 控制項狀態納入考慮,包括資料行或資料列跨越,以及 當 放置控制項且其 ColumnRow 屬性設定為 -1 時 TableLayoutPanel.LayoutEngine

適用於

另請參閱