DataGrid.PreferredRowHeight Property


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)

public int PreferredRowHeight { get; set; }

Property Value

Type: System.Int32

The height of a row.

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;

.NET Framework
Available since 1.1
Return to top