DataGridViewColumnHeaderCell.GetPreferredSize(Graphics, DataGridViewCellStyle, Int32, Size) DataGridViewColumnHeaderCell.GetPreferredSize(Graphics, DataGridViewCellStyle, Int32, Size) DataGridViewColumnHeaderCell.GetPreferredSize(Graphics, DataGridViewCellStyle, Int32, Size) Method

定义

计算单元格的首选大小(以像素为单位)。Calculates the preferred size, in pixels, of the cell.

protected:
 override System::Drawing::Size GetPreferredSize(System::Drawing::Graphics ^ graphics, System::Windows::Forms::DataGridViewCellStyle ^ cellStyle, int rowIndex, System::Drawing::Size constraintSize);
protected override System.Drawing.Size GetPreferredSize (System.Drawing.Graphics graphics, System.Windows.Forms.DataGridViewCellStyle cellStyle, int rowIndex, System.Drawing.Size constraintSize);
override this.GetPreferredSize : System.Drawing.Graphics * System.Windows.Forms.DataGridViewCellStyle * int * System.Drawing.Size -> System.Drawing.Size

参数

graphics
Graphics Graphics Graphics

用于绘制单元格的 GraphicsThe Graphics used to draw the cell.

cellStyle
DataGridViewCellStyle DataGridViewCellStyle DataGridViewCellStyle

一个 DataGridViewCellStyle ,它表示单元格样式。A DataGridViewCellStyle that represents the style of the cell.

rowIndex
Int32 Int32 Int32

单元格的从零开始的行索引。The zero-based row index of the cell.

constraintSize
Size Size Size

单元格允许的最大大小。The cell's maximum allowable size.

返回

一个 Size,它表示单元格的首选大小(以像素为单位)。A Size that represents the preferred size, in pixels, of the cell.

异常

适用于

另请参阅