次の方法で共有


DataGrid.PreferredRowHeight プロパティ

System.Windows.Forms.DataGrid コントロールの行の適切な高さを取得または設定します。

Public Property PreferredRowHeight As Integer
[C#]
public int PreferredRowHeight {get; set;}
[C++]
public: __property int get_PreferredRowHeight();public: __property void set_PreferredRowHeight(int);
[JScript]
public function get PreferredRowHeight() : int;public function set PreferredRowHeight(int);

プロパティ値

行の高さ。

解説

このプロパティを設定してから、 DataSource プロパティと DataMember プロパティを個別または SetDataBinding メソッドを通じてリセットします。この操作を行わないと、このプロパティを有効にすることはできません。

使用例

[Visual Basic, C#, C++] 新しいフォントを設定してから、 PreferredRowHeight を新しいフォントと同じ高さに設定する例を次に示します。

 
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


[C#] 
private void ChangeFontHeight(DataGrid myGrid)
{
   myGrid.Font = new System.Drawing.Font
      ("Microsoft Sans Serif",
      15, System.Drawing.FontStyle.Regular);
   myGrid.PreferredRowHeight = myGrid.Font.Height;
}


[C++] 
private:
void ChangeFontHeight(DataGrid* myGrid)
{
   myGrid->Font = new System::Drawing::Font
      (S"Microsoft Sans Serif",
      15, System::Drawing::FontStyle::Regular);
   myGrid->PreferredRowHeight = myGrid->Font->Height;
}

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

DataGrid クラス | DataGrid メンバ | System.Windows.Forms 名前空間 | GetPreferredHeight | PreferredColumnWidth