TableLayoutControlCollection.Add(Control, Int32, Int32) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將指定的控制項加入集合,並將其定位於指定的儲存格。
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到特定儲存格,或者只指定欄位或列值,並讓它rowLayoutEngine放在下一個開放儲存格control的位置。 這稱為讓控制流 向 控制裝置中的位置 TableLayoutPanel 。
如果你想column佔據固定的排位,請設control為 -1。
如果你想row佔據固定欄位位置,請設control為 -1。
若 與 column 皆非 row 為 -1,則 control 將在絕對位置加 (column, row)。
如果你把 和 column 都row設為 -1,control將會流向第一個開放位置,具體的流動行為由 TableLayoutPanel.GrowStyle 值定義。 這等同於使用該 Control.ControlCollection.Add 方法。
要找到控制項的實際當前位置,請使用該 TableLayoutPanel.GetPositionFromControl 方法。 此方法考量整個TableLayoutPanel控制狀態,包括欄位或列生成,以及當TableLayoutPanel.LayoutEngine控制點設定ColumnRow為 -1 時。