DataGridViewEditMode 枚举


指定用户如何在 DataGridView 控件中启动单元格编辑。Specifies how a user starts cell editing in the DataGridView control.

public enum class DataGridViewEditMode
public enum DataGridViewEditMode
type DataGridViewEditMode = 
Public Enum DataGridViewEditMode


EditOnEnter 0

当单元格接收到焦点时即可开始编辑。Editing begins when the cell receives focus. 在按 Tab 键在行中横向输入值,或按 Enter 键在列中纵向输入值时,此模式非常有用。This mode is useful when pressing the TAB key to enter values across a row, or when pressing the ENTER key to enter values down a column.

EditOnF2 3

当单元格获得焦点时按 F2 开始编辑。Editing begins when F2 is pressed while the cell has focus. 此模式将选择点放置在单元格内容的末尾。This mode places the selection point at the end of the cell contents.

EditOnKeystroke 1

当单元格获得焦点时按任意字母数字键开始编辑。Editing begins when any alphanumeric key is pressed while the cell has focus.

EditOnKeystrokeOrF2 2

当单元格获得焦点时按任意字母数字键或 F2 开始编辑。Editing begins when any alphanumeric key or F2 is pressed while the cell has focus.

EditProgrammatically 4

仅在调用 BeginEdit(Boolean) 方法时开始编辑。Editing begins only when the BeginEdit(Boolean) method is called.


下面的代码示例演示如何使用此类型。The following code example illustrates the use of this type. 有关详细信息,请参阅如何:指定 Windows 窗体 DataGridView 控件的编辑模式。For more information, see How to: Specify the Edit Mode for the Windows Forms DataGridView Control.

this.dataGridView1.EditMode = DataGridViewEditMode.EditOnEnter;
Me.dataGridView1.EditMode = DataGridViewEditMode.EditOnEnter


此枚举由EditMode DataGridView控件的属性使用。This enumeration is used by the EditMode property of the DataGridView control.

DataGridViewEditMode EditProgrammatically 以外的所有值都允许用户双击某个单元以开始编辑它。All DataGridViewEditMode values except for EditProgrammatically allow a user to double-click a cell to begin editing it.