DataGridViewCell.GetPreferredSize メソッド

定義

セルの推奨されるサイズをピクセル単位で計算します。

protected:
 virtual System::Drawing::Size GetPreferredSize(System::Drawing::Graphics ^ graphics, System::Windows::Forms::DataGridViewCellStyle ^ cellStyle, int rowIndex, System::Drawing::Size constraintSize);
protected virtual System.Drawing.Size GetPreferredSize (System.Drawing.Graphics graphics, System.Windows.Forms.DataGridViewCellStyle cellStyle, int rowIndex, System.Drawing.Size constraintSize);
abstract member GetPreferredSize : System.Drawing.Graphics * System.Windows.Forms.DataGridViewCellStyle * int * System.Drawing.Size -> System.Drawing.Size
override this.GetPreferredSize : System.Drawing.Graphics * System.Windows.Forms.DataGridViewCellStyle * int * System.Drawing.Size -> System.Drawing.Size
Protected Overridable Function GetPreferredSize (graphics As Graphics, cellStyle As DataGridViewCellStyle, rowIndex As Integer, constraintSize As Size) As Size

パラメーター

graphics
Graphics

セルの描画に使用する Graphics

cellStyle
DataGridViewCellStyle

セルのスタイルを表す DataGridViewCellStyle

rowIndex
Int32

セルの 0 から始まる行インデックス番号。

constraintSize
Size

セルの最大許容サイズ。

戻り値

Size

セルの推奨されるサイズをピクセル単位で表す Size

注釈

基底クラスDataGridViewCellのメソッドはGetPreferredSize、常に幅と高さが -1 の a Size を返します。 ただし、このメソッドは、適切な値を返すために、派生セル クラスでオーバーライドされます。

適用対象

こちらもご覧ください