DataGridTableStyle.PreferredRowHeight 属性

定义

获取或设置在显示新网格时创建行所用的高度。

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

属性值

Int32

行的高度(以像素为单位)。

示例

下面的代码示例演示了此成员的使用。

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)

注解

首选高度是容纳所显示文本所需的最小高度,其分配 HeaderFont。 不会创建高度小于指定值的行。 但是,如果字号需要它,则行高可能大于指定的值。

适用于

另请参阅