DataGridTableStyle.PreferredRowHeight Propriété

Définition

Obtient ou définit la hauteur utilisée pour créer une ligne quand une nouvelle grille est affichée.

public:
 property int PreferredRowHeight { int get(); void set(int value); };
public int PreferredRowHeight { get; set; }
member this.PreferredRowHeight : int with get, set
Public Property PreferredRowHeight As Integer

Valeur de propriété

Int32

Hauteur d'une ligne, en pixels.

Exemples

L’exemple de code suivant illustre l’utilisation de ce membre.

int myPreferredRowHeight = Convert::ToInt32( myTextBox->Text->Trim() );
if ( myPreferredRowHeight < 18 || myPreferredRowHeight > 134 )
{
   MessageBox::Show( "Enter the height between 18 and 134" );
   return;
}

// Set the 'PreferredRowHeight' property of DataGridTableStyle instance.
myTableStyle->PreferredRowHeight = myPreferredRowHeight;

// Add the DataGridTableStyle instance to the GridTableStylesCollection.
myDataGrid->TableStyles->Add( myTableStyle );
int myPreferredRowHeight=Convert.ToInt32(myTextBox.Text.Trim());
if(myPreferredRowHeight<18 || myPreferredRowHeight >134)
{
   MessageBox.Show("Enter the height between 18 and 134");
   return;
}
// Set the 'PreferredRowHeight' property of DataGridTableStyle instance.
myTableStyle.PreferredRowHeight=myPreferredRowHeight;
// Add the DataGridTableStyle instance to the GridTableStylesCollection. 
myDataGrid.TableStyles.Add(myTableStyle);
Dim myPreferredRowHeight As Integer = Convert.ToInt32(myTextBox.Text.Trim())
If myPreferredRowHeight < 18 Or myPreferredRowHeight > 134 Then
    MessageBox.Show("Enter the height between 18 and 134")
    Return
End If
' Set the 'PreferredRowHeight' property of DataGridTableStyle instance.
myTableStyle.PreferredRowHeight = myPreferredRowHeight
' Add the DataGridTableStyle instance to the GridTableStylesCollection. 
myDataGrid.TableStyles.Add(myTableStyle)

Remarques

La hauteur par défaut est la hauteur minimale nécessaire pour prendre en charge le texte affiché avec l’attribut HeaderFont. Une ligne ne sera pas créée avec une hauteur inférieure à la valeur spécifiée. Si la taille de police l’exige, toutefois, la hauteur de ligne peut être supérieure à la valeur spécifiée.

S’applique à

Voir aussi