DataGridViewCell.GetInheritedState(Int32) 方法

定义

返回一个值,该值指示此单元格从它的行和列的状态继承后的当前状态。Returns a value indicating the current state of the cell as inherited from the state of its row and column.

public:
 virtual System::Windows::Forms::DataGridViewElementStates GetInheritedState(int rowIndex);
public virtual System.Windows.Forms.DataGridViewElementStates GetInheritedState (int rowIndex);
abstract member GetInheritedState : int -> System.Windows.Forms.DataGridViewElementStates
override this.GetInheritedState : int -> System.Windows.Forms.DataGridViewElementStates
Public Overridable Function GetInheritedState (rowIndex As Integer) As DataGridViewElementStates

参数

rowIndex
Int32

包含该单元格的行的索引。The index of the row containing the cell.

返回

DataGridViewElementStates 值的按位组合,表示单元格的当前状态。A bitwise combination of DataGridViewElementStates values representing the current state of the cell.

异常

该单元格不包含在 DataGridView 控件中,且 rowIndex 不为 -1。The cell is not contained within a DataGridView control and rowIndex is not -1.

-or- rowIndex 不是包含此单元格的行的索引。rowIndex is not the index of the row containing this cell.

该单元格包含在 DataGridView 控件中,且 rowIndex 不在有效范围(从 0 至控件中的行数减 1)内。The cell is contained within a DataGridView control and rowIndex is outside the valid range of 0 to the number of rows in the control minus 1.

注解

此方法可用于确定共享行中单元格的状态。This method is useful to determine the state of a cell in a shared row. 共享行的 Index 值为-1,这将阻止您将 InheritedState 属性与共享行中的单元格一起使用。Shared rows have Index values of -1, which prevents you from using the InheritedState property with cells in shared rows. 若要使用此方法,请传入包含此单元格的行的实际索引。To use this method, pass in the actual index of the row containing this cell. 可以通过调用 IndexOf 方法来检索共享行的实际索引。You can retrieve the actual index of a shared row by calling the IndexOf method.

适用于

另请参阅