DataGridViewCell.DataGridViewCellAccessibleObject.DoDefaultAction Method


执行与 DataGridViewCell.DataGridViewCellAccessibleObject 关联的默认操作。Performs the default action associated with the DataGridViewCell.DataGridViewCellAccessibleObject.

 override void DoDefaultAction();
public override void DoDefaultAction ();
override this.DoDefaultAction : unit -> unit
Public Overrides Sub DoDefaultAction ()


Owner 属性的值为 nullThe value of the Owner property is null.

- 或 --or- DataGridViewCell.DataGridViewCellAccessibleObject 属性的值不为 null,并且 RowIndex 属性返回的 DataGridViewCellOwner 属性等于 -1。The value of the DataGridViewCell.DataGridViewCellAccessibleObject property is not null and the RowIndex property of the DataGridViewCell returned by the Owner property is equal to -1.


如果与此 DataGridViewCell.DataGridViewCellAccessibleObject 关联的单元格是 DataGridViewHeaderCell,则此方法不执行任何操作。If the cell associated with this DataGridViewCell.DataGridViewCellAccessibleObject is a DataGridViewHeaderCell, this method does nothing. 否则,此方法将选择单元格,使其成为当前单元格,并执行以下操作之一:Otherwise, this method selects the cell, makes it the current cell, and takes one of the following actions:

  • 如果该单元格的 ReadOnly 属性值为 true,则此方法返回。If the cell's ReadOnly property value is true, this method returns.

  • 如果该单元格的 EditType 属性值为 null,表示该单元不能承载编辑控件,则此方法返回。If the cell's EditType property value is null, meaning the cell cannot host an editing control, this method returns.

  • 如果该单元格当前正在进入或离开编辑模式(例如,如果在 CellBeginEditCellEndEdit 事件处理程序中调用此方法),则此方法返回。If the cell is currently entering or leaving edit mode (for example, if this method is called in a CellBeginEdit or CellEndEdit event handler), this method returns.

  • 如果该单元格当前处于编辑模式,则此方法提交并结束编辑。If the cell is currently in edit mode, this method commits and ends the edit.

  • 如果该单元格未处于编辑模式,并且 DataGridView.EditMode 属性设置为 EditProgrammatically,则此方法返回。If the cell is not in edit mode and the DataGridView.EditMode property is set to EditProgrammatically, this method returns.

  • 如果未执行上述操作,则此方法会导致单元格进入编辑模式。If none of the preceding actions is taken, this method causes the cell to enter edit mode.

Applies to

See also