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

プロパティ値

行の高さ。

次のコード例では、最初に新しいフォントを設定し、 を 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

注釈

このプロパティは、DataSource プロパティと DataMember プロパティを (個別に、または SetDataBinding メソッドを使用して) リセットする前に設定してください。そうしないと、プロパティの設定が反映されません。

適用対象

こちらもご覧ください