TableLayoutPanel.GetRow(Control) Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns the row position of the specified child control.
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
A child control of the TableLayoutPanel.
The row position of control
, or -1 if the position of control
is determined by LayoutEngine.
control
is null
.
control
is not a type that can be arranged by this LayoutEngine.
The following code example enumerates all the child controls in the TableLayoutPanel and finds the row index for each using the GetRow method.
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
If control
spans two or more rows, the GetRow method will return the lowest row index.
The row position value is zero based, so you can use it as an index for the array returned by GetRowHeights.
This method is called by the Row
property, which the panel adds to its child controls at design time.
To get the actual position of control
, even when its position is determined by LayoutEngine, call the GetPositionFromControl method.
Product | Versions |
---|---|
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
.NET feedback
.NET is an open source project. Select a link to provide feedback: