System.Windows.Forms.DataGridView.BeginEdit Method

Puts the current cell in edit mode.

Syntax

public virtual bool BeginEdit (bool selectAll)

Parameters

selectAll
true to select all the cell's contents; false to not select any contents.

Returns

true if the current cell is already in edit mode or successfully enters edit mode; otherwise, false.

Remarks

This method returns false if the cell fails to enter edit mode, which can happen for a number of reasons. This method returns false if the current cell is read-only. It also returns false if the cell DataGridViewCell.EditType property is null (meaning the cell cannot host an editing control) and the cell type does not implement the System.Windows.Forms.IDataGridViewEditingCell interface.

If the cell supports editing, this method raises the DataGridView.CellBeginEdit event, which can be canceled, and returns false if an event handler cancels the edit. If the edit is not canceled and the cell can host an editing control, this method initializes the control and displays it. If the initialization fails, this method returns false.

If the cell successfully enters edit mode, the DataGridView.IsCurrentCellInEditMode property returns true.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0