TableLayoutPanel.SetRow(Control, Int32) Méthode

Définition

Définit la position de ligne du contrôle enfant spécifié.

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 -> unit
Public Sub SetRow (control As Control, row As Integer)

Paramètres

control
Control

Contrôle à déplacer vers une autre ligne.

row
Int32

Ligne vers laquelle control doit être déplacé.

Exemples

L’exemple de code suivant utilise la SetColumn méthode pour échanger deux contrôles contenus dans un TableLayoutPanel contrôle. L’exemple suppose un TableLayoutPanel contrôle avec au moins deux lignes.

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

Remarques

La SetRow méthode déplace le contrôle vers une autre ligne du TableLayoutPanel contrôle. Les colonnes et les lignes ont des index basés sur zéro. La définition de la position de ligne sur -1 spécifie que le contrôle va passer à la première cellule vide.

Cette méthode réapplique la disposition de la table à tous les contrôles dans le TableLayoutPanel.

Cette méthode est appelée par la propriété, que le panneau ajoute à ses contrôles enfants au moment de la Row conception.

S’applique à

Voir aussi