DataGridViewHeaderCell.GetSize(Int32) DataGridViewHeaderCell.GetSize(Int32) DataGridViewHeaderCell.GetSize(Int32) DataGridViewHeaderCell.GetSize(Int32) Method

定义

获取单元格的大小。Gets the size of the cell.

protected:
 override System::Drawing::Size GetSize(int rowIndex);
protected override System.Drawing.Size GetSize (int rowIndex);
override this.GetSize : int -> System.Drawing.Size
Protected Overrides Function GetSize (rowIndex As Integer) As Size

参数

rowIndex
Int32 Int32 Int32 Int32

标头单元格的行索引。The row index of the header cell.

返回

Size,它表示标头单元格的大小。A Size that represents the size of the header cell.

异常

此单元格的 DataGridView 属性值是 null,而且 rowIndex 不等于 -1。The value of the DataGridView property for this cell is null and rowIndex does not equal -1.

- 或 --or- 此单元格的 OwningColumn 属性值不是 null,而且 rowIndex 不等于 -1。The value of the OwningColumn property for this cell is not null and rowIndex does not equal -1.

- 或 --or- 此单元格的 OwningRow 属性值不是 null,而且 rowIndex 小于零或者大于等于控件中的行数。The value of the OwningRow property for this cell is not null and rowIndex is less than zero or greater than or equal to the number of rows in the control.

- 或 --or- 此单元格的 OwningColumnOwningRow 属性值都是 null,而且 rowIndex 不等于 -1。The values of the OwningColumn and OwningRow properties of this cell are both null and rowIndex does not equal -1.

此单元格的 OwningRow 属性值不是 null,而且 rowIndex 指示的是 OwningRow 以外的行。The value of the OwningRow property for this cell is not null and rowIndex indicates a row other than the OwningRow.

注解

GetSize方法返回的大小可以根据列标题的行中,如果该标头单元格的列标题、 大小可以根据行标题的列中,如果该标头单元格行标题或大小需要成为DataGridViewTopLeftHeaderCell如果该单元格左上方标头单元格。The GetSize method returns the size necessary to fit in a row of column headers if the header cell is a column header, the size necessary to fit in a column of row headers if the header cell is a row header, or the size necessary to be a DataGridViewTopLeftHeaderCell if the cell is a top left header cell.

如果该单元格未附加到DataGridView,则Size属性的DataGridViewHeaderCell返回 (-1,-1) 的值。If the cell is not attached to a DataGridView, the Size property of the DataGridViewHeaderCell returns the value (-1,-1).

适用于

另请参阅