Επεξεργασία

Κοινή χρήση μέσω


DataGridTableStyle.PreferredRowHeight Property

Definition

Gets or sets the height used to create a row when a new grid is displayed.

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

Property Value

The height of a row, in pixels.

Examples

The following code example demonstrates the use of this member.

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)

Remarks

The preferred height is the minimum height needed to accommodate the displayed text with the assigned HeaderFont. A row will not be created with a height less than the specified value. If the font size requires it, however, the row height may be greater than the specified value.

Applies to

See also