DataGridTableStyle.PreferredRowHeight Property

Definition

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

C#
public int PreferredRowHeight { get; set; }

Property Value

The height of a row, in pixels.

Examples

The following code example demonstrates the use of this member.

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 '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

Proizvod Verzije
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 10

See also