DataGridViewCell.GetPreferredSize 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
计算单元格的首选大小(以像素为单位)。
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
参数
- cellStyle
- DataGridViewCellStyle
一个 DataGridViewCellStyle,它表示单元格样式。
- rowIndex
- Int32
单元格的从零开始的行索引。
- constraintSize
- Size
单元格允许的最大大小。
返回
一个 Size,它表示单元格的首选大小(以像素为单位)。
注解
GetPreferredSize基类DataGridViewCell中的 方法始终返回Size宽度和高度为 -1 的 。 但是,此方法在派生单元格类中被重写,以返回正确的值。