DataGridViewTopLeftHeaderCell.GetPreferredSize(Graphics, DataGridViewCellStyle, Int32, Size) 方法
定义
计算单元格的首选大小(以像素为单位)。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
Protected Overrides Function GetPreferredSize (graphics As Graphics, cellStyle As DataGridViewCellStyle, rowIndex As Integer, constraintSize As Size) As Size
参数
- cellStyle
- DataGridViewCellStyle
一个 DataGridViewCellStyle,它表示单元格样式。A DataGridViewCellStyle that represents the style of the cell.
- rowIndex
- Int32
单元格的从零开始的行索引。The zero-based row index of the cell.
- constraintSize
- Size
单元格允许的最大大小。The cell's maximum allowable size.
返回
一个 Size,它表示单元格的首选大小(以像素为单位)。A Size that represents the preferred size, in pixels, of the cell.
例外
rowIndex
不等于 -1。rowIndex
does not equal -1.
注解
此方法依赖于 DataGridViewCell.GetFormattedValue 方法。This method relies on the DataGridViewCell.GetFormattedValue method.