DataGridView.SetCurrentCellAddressCore(Int32, Int32, Boolean, Boolean, Boolean) 方法

定义

设置当前处于活动状态的单元格。Sets the currently active cell.

protected:
 virtual bool SetCurrentCellAddressCore(int columnIndex, int rowIndex, bool setAnchorCellAddress, bool validateCurrentCell, bool throughMouseClick);
protected virtual bool SetCurrentCellAddressCore (int columnIndex, int rowIndex, bool setAnchorCellAddress, bool validateCurrentCell, bool throughMouseClick);
abstract member SetCurrentCellAddressCore : int * int * bool * bool * bool -> bool
override this.SetCurrentCellAddressCore : int * int * bool * bool * bool -> bool
Protected Overridable Function SetCurrentCellAddressCore (columnIndex As Integer, rowIndex As Integer, setAnchorCellAddress As Boolean, validateCurrentCell As Boolean, throughMouseClick As Boolean) As Boolean

参数

columnIndex
Int32

包含单元格的列的索引。The index of the column containing the cell.

rowIndex
Int32

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

setAnchorCellAddress
Boolean

如果将新的当前单元格用作使用 Shift 键选择的后续多个单元格的定位单元格,则为 true;否则为 falsetrue to make the new current cell the anchor cell for a subsequent multicell selection using the SHIFT key; otherwise, false.

validateCurrentCell
Boolean

如果要验证旧的当前单元格中的值并在验证失败时取消更改,则为 true;否则为 falsetrue to validate the value in the old current cell and cancel the change if validation fails; otherwise, false.

throughMouseClick
Boolean

如果当前的单元格是通过单击鼠标设置的,则为 true;否则为 falsetrue if the current cell is being set as a result of a mouse click; otherwise, false.

返回

如果当前单元格设置成功,则为 true;否则为 falsetrue if the current cell was successfully set; otherwise, false.

异常

columnIndex 小于 0 或大于控件中的列数减 1,并且 rowIndex 不是 -1。columnIndex is less than 0 or greater than the number of columns in the control minus 1, and rowIndex is not -1.

-or- rowIndex 小于 0 或大于控件中的行数减 1,并且 columnIndex 不是 -1。rowIndex is less than 0 or greater than the number of rows in the control minus 1, and columnIndex is not -1.

指定单元格的 Visible 属性值为 falseThe specified cell has a Visible property value of false.

-or- 已调用此方法,但其原因不是因为正在重置基础数据源,且另一个线程当前正在执行此方法。This method was called for a reason other than the underlying data source being reset, and another thread is currently executing this method.

新的当前单元格尝试进入编辑模式,但是它的 EditType 属性不指示从 Control 派生并实现 IDataGridViewEditingControl 的类。The new current cell tried to enter edit mode, but its EditType property does not indicate a class that derives from Control and implements IDataGridViewEditingControl.

注解

每次更改当前单元格时,@no__t 0 控件都将使用此方法。The DataGridView control uses this method whenever it changes the current cell. 此方法将更改当前单元格,而不会更改选择,也可以选择不验证上一个单元格或更改选择定位点单元格。This method changes the current cell without changing the selection and optionally without validating the previous cell or changing the selection anchor cell. 定位单元格是多个单元格块的第一个单元格,用户可以通过按住 SHIFT 键并单击块的最后一个单元格来选择该单元格。The anchor cell is the first cell of a block of multiple cells that the user can select by holding down the SHIFT key and clicking the last cell of the block.

如果 rowIndex,并且 columnIndex 同时为-1,则 @no__t 2 属性将返回 nullIf rowIndex and columnIndex are both -1, the CurrentCell property returns null.

适用于

另请参阅