DataGridViewHeaderCell.GetSize(Int32) 方法

定义

获取单元格的大小。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

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

返回

Size

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.

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

适用于

另请参阅