TableLayoutPanel.SetRow(Control, Int32) 方法    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
设置指定子控件的行位置。
public:
 void SetRow(System::Windows::Forms::Control ^ control, int row);public void SetRow (System.Windows.Forms.Control control, int row);member this.SetRow : System.Windows.Forms.Control * int -> unitPublic Sub SetRow (control As Control, row As Integer)参数
- control
- Control
要移至另一行的控件。
- row
- Int32
control 将移动到的行。
示例
下面的代码示例使用 SetColumn 该方法交换控件中包含的两个 TableLayoutPanel 控件。 该示例假定控件 TableLayoutPanel 至少有两行。
private void swapRowsBtn_Click(
    System.Object sender, 
    System.EventArgs e)
{
    Control c1 = this.TableLayoutPanel1.GetControlFromPosition(0, 0);
    Control c2 = this.TableLayoutPanel1.GetControlFromPosition(1, 0);
    if ( c1 !=null && c2 != null )
    {
        this.TableLayoutPanel1.SetRow(c2, 0);
        this.TableLayoutPanel1.SetRow(c1, 1);
    }
}
Private Sub swapRowsBtn_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles swapRowsBtn.Click
    Dim c1 As Control = Me.TableLayoutPanel1.GetControlFromPosition(0, 0)
    Dim c2 As Control = Me.TableLayoutPanel1.GetControlFromPosition(1, 0)
    If c1 IsNot Nothing And c2 IsNot Nothing Then
        Me.TableLayoutPanel1.SetRow(c2, 0)
        Me.TableLayoutPanel1.SetRow(c1, 1)
    End If
End Sub
注解
该方法 SetRow 将控件移动到控件中的 TableLayoutPanel 另一行。 列和行具有从零开始的索引。 将行位置设置为 -1 指定控件将流向第一个空单元格。
此方法将表布局重新分配给该 TableLayoutPanel控件中的所有控件。
此方法由 Row 属性调用,面板在设计时将其添加到其子控件中。