DataGridView.SetCurrentCellAddressCore 方法

定义

设置当前处于活动状态的单元格。

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

包含单元格的列的索引。

rowIndex
Int32

包含该单元格的行的索引。

setAnchorCellAddress
Boolean

true to make the new current cell the anchor cell for a subsequent multicell selection using the SHIFT key; otherwise, false.

validateCurrentCell
Boolean

true to validate the value in the old current cell and cancel the change if validation fails; otherwise, false.

throughMouseClick
Boolean

如果当前的单元格是通过单击鼠标设置的,则为 true;否则为 false

返回

Boolean

如果当前单元格设置成功,则为 true;否则为 false

例外

columnIndex 小于 0 或大于控件中的列数减 1,并且 rowIndex 不是 -1。

  • 或 - rowIndex 小于 0 或大于控件中的行数减 1,并且 columnIndex 不是 -1。

指定单元格的 Visible 属性值为 false

  • 或 - 已调用此方法,但其原因不是因为正在重置基础数据源,且另一个线程当前正在执行此方法。

新的当前单元格尝试进入编辑模式,但是它的 EditType 属性不指示从 Control 派生并实现 IDataGridViewEditingControl 的类。

注解

每当控件更改当前单元格时,该 DataGridView 控件都使用此方法。 此方法在不更改选定内容的情况下更改当前单元格,也可以选择更改上一个单元格或更改选择定位点单元格。 定位单元是用户可以选择的多个单元格块的第一个单元格,方法是按住 SHIFT 键并单击块的最后一个单元格。

如果同时rowIndex为 -1,则CurrentCell属性返回 nullcolumnIndex

适用于

另请参阅