PreferredRowHeight Property

DataGridTableStyle.PreferredRowHeight Property

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

[Visual Basic]
Public Property PreferredRowHeight As Integer
[C#]
public int PreferredRowHeight {get; set;}
[C++]
public: __property int get_PreferredRowHeight();
public: __property void set_PreferredRowHeight(int);
[JScript]
public function get PreferredRowHeight() : int;
public function set PreferredRowHeight(int);

Property Value

The height of a row in pixels.

Remarks

The preferred height is the minimum height needed to accommodate the displayed text with the assigned HeaderFont.

Example

[Visual Basic] 
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 'PrefferedRowHeight' property of DataGridTableStyle instance.
myTableStyle.PreferredRowHeight = myPreferredRowHeight
' Add the DataGridTableStyle instance to the GridTableStylesCollection. 
myDataGrid.TableStyles.Add(myTableStyle)

[C#] 
int myPreferredRowHeight=Convert.ToInt32(myTextBox.Text.Trim());
if(myPreferredRowHeight<18 || myPreferredRowHeight >134)
{
   MessageBox.Show("Enter the height between 18 and 134");
   return;
}
// Set the 'PrefferedRowHeight' property of DataGridTableStyle instance.
myTableStyle.PreferredRowHeight=myPreferredRowHeight;
// Add the DataGridTableStyle instance to the GridTableStylesCollection. 
myDataGrid.TableStyles.Add(myTableStyle);

[C++] 
int myPreferredRowHeight=Convert::ToInt32(myTextBox->Text->Trim());
if (myPreferredRowHeight<18 || myPreferredRowHeight >134) {
    MessageBox::Show(S"Enter the height between 18 and 134");
    return;
}
// Set the 'PrefferedRowHeight' property of DataGridTableStyle instance.
myTableStyle->PreferredRowHeight=myPreferredRowHeight;
// Add the DataGridTableStyle instance to the GridTableStylesCollection.
myDataGrid->TableStyles->Add(myTableStyle);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

DataGridTableStyle Class | DataGridTableStyle Members | System.Windows.Forms Namespace | HeaderFont | PreferredColumnWidth

Show:
© 2016 Microsoft