TableLayoutPanel.GetRow(Control) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
回傳指定子控制項的列位置。
public:
int GetRow(System::Windows::Forms::Control ^ control);
public int GetRow(System.Windows.Forms.Control control);
member this.GetRow : System.Windows.Forms.Control -> int
Public Function GetRow (control As Control) As Integer
參數
- control
- Control
一個子控。TableLayoutPanel
傳回
control若 的位置control由 決定LayoutEngine,則為 -1 。
例外狀況
control 是 null。
control 不是一個可以用此 LayoutEngine方式排列的類型。
範例
以下程式碼範例列舉了 中 TableLayoutPanel 所有子控制項,並利用該 GetRow 方法查找每個子控制項的列索引。
private void getRowBtn_Click(
System.Object sender,
System.EventArgs e)
{
foreach ( Control c in this.TableLayoutPanel1.Controls )
{
Trace.WriteLine(this.TableLayoutPanel1.GetRow(c));
}
}
Private Sub getRowBtn_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles getRowBtn.Click
Dim c As Control
For Each c In Me.TableLayoutPanel1.Controls
Trace.WriteLine(Me.TableLayoutPanel1.GetRow(c))
Next
End Sub
備註
若 control 跨跨兩列或以上, GetRow 方法會回傳最低的列索引。
列位置值是以零為基礎,因此你可以用它作為由 回傳 GetRowHeights的陣列索引。
此方法由 Row property 呼叫,面板在設計時將其加入子控制項。
即使其位置由 決定control,也要取得 的實際位置LayoutEngine,呼叫該GetPositionFromControl方法。