TableLayoutPanel.RowStyles Propriété

Définition

Obtient une collection de styles de ligne pour TableLayoutPanel.

public:
 property System::Windows::Forms::TableLayoutRowStyleCollection ^ RowStyles { System::Windows::Forms::TableLayoutRowStyleCollection ^ get(); };
[System.ComponentModel.Browsable(false)]
public System.Windows.Forms.TableLayoutRowStyleCollection RowStyles { get; }
[<System.ComponentModel.Browsable(false)>]
member this.RowStyles : System.Windows.Forms.TableLayoutRowStyleCollection
Public ReadOnly Property RowStyles As TableLayoutRowStyleCollection

Valeur de propriété

TableLayoutRowStyleCollection

TableLayoutRowStyleCollection contenant un RowStyle pour chaque ligne du contrôle TableLayoutPanel.

Attributs

Exemples

L’exemple de code suivant définit les RowStyle propriétés de chaque ligne lorsqu’un Button clic est fait.

private void toggleRowStylesBtn_Click(
    System.Object sender, 
    System.EventArgs e)
{
    TableLayoutRowStyleCollection styles = 
        this.TableLayoutPanel1.RowStyles;

    foreach( RowStyle style in styles )
    {
        if (style.SizeType==SizeType.Absolute)
        {
            style.SizeType = SizeType.AutoSize;
        }
        else if(style.SizeType==SizeType.AutoSize)
        {
            style.SizeType = SizeType.Percent;

            // Set the row height to be a percentage
            // of the TableLayoutPanel control's height.
            style.Height = 33;
        }
        else
        {

            // Set the row height to 50 pixels.
            style.SizeType = SizeType.Absolute;
            style.Height = 50;
        }
    }
}
Private Sub toggleRowStylesBtn_Click( _
ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles toggleRowStylesBtn.Click

    Dim styles As TableLayoutRowStyleCollection = _
    Me.TableLayoutPanel1.RowStyles

    For Each style As RowStyle In styles

        If style.SizeType = SizeType.Absolute Then

            style.SizeType = SizeType.AutoSize

        ElseIf style.SizeType = SizeType.AutoSize Then

            style.SizeType = SizeType.Percent

            ' Set the row height to be a percentage
            ' of the TableLayoutPanel control's height.
            style.Height = 33

        Else

            ' Set the row height to 50 pixels.
            style.SizeType = SizeType.Absolute
            style.Height = 50

        End If

    Next

End Sub

Remarques

Utilisez la RowStyles propriété pour accéder aux propriétés de style de lignes spécifiques. Vous pouvez utiliser des membres de la RowStyle classe pour définir les caractéristiques des lignes individuelles dans la table.

Lorsque le TableLayoutPanel contrôle organise ses lignes, il affecte des priorités à chacun RowStyle dans l’ordre suivant :

  1. Les lignes dont RowStyle la valeur est définie Absolute sont considérées en premier et leurs hauteurs fixes sont allouées.

  2. Les lignes dont RowStyle l’ensemble AutoSize est défini sont dimensionnées sur leur contenu.

  3. L’espace restant est divisé entre les lignes avec RowStyle la valeur Percentdéfinie sur .

S’applique à

Voir aussi