Share via


DataGrid.PreferredRowHeight 屬性

定義

取得或設定 DataGrid 控制項的慣用資料列高度。

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

資料列的高度。

範例

下列程式碼範例會先設定新的字型,並將 設定 PreferredRowHeight 為與新字型相同的高度。

private:
   void ChangeFontHeight( DataGrid^ myGrid )
   {
      myGrid->Font = gcnew System::Drawing::Font(
         "Microsoft Sans Serif",
         15, System::Drawing::FontStyle::Regular );
      myGrid->PreferredRowHeight = myGrid->Font->Height;
   }
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 Sub ChangeFontHeight(ByVal myGrid As DataGrid)
   ' Change the font first.
   myGrid.Font = New System.Drawing.Font _
   ("Microsoft Sans Serif", 15, _
   System.Drawing.FontStyle.Regular)

   myGrid.PreferredRowHeight = myGrid.Font.Height
End Sub

備註

在個別重設 和 屬性之前,請先設定此屬性,或透過 SetDataBinding 方法) 重設 DataSourceDataMember (屬性,否則屬性將不會有任何作用。

適用於

另請參閱