DataGrid.PreferredRowHeight Property
.NET Framework 3.0
Gets or sets the preferred row height for the System.Windows.Forms.DataGrid control.
Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Set this property before resetting the DataSource and DataMember properties (either separately, or through the SetDataBinding method), or the property will have no effect.
The following code example first sets a new font, and sets the PreferredRowHeight to the same height as the new font.
private void ChangeFontHeight(DataGrid myGrid) { myGrid.Font = new System.Drawing.Font ("Microsoft Sans Serif", 15, System.Drawing.FontStyle.Regular); myGrid.PreferredRowHeight = myGrid.Font.Height; }
private void ChangeFontHeight(DataGrid myGrid)
{
myGrid.set_Font(new System.Drawing.Font(
"Microsoft Sans Serif", 15, System.Drawing.FontStyle.Regular));
myGrid.set_PreferredRowHeight(myGrid.get_Font().get_Height());
} //ChangeFontHeight
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.