DataGridView.CellBeginEdit Event

Definition

Occurs when edit mode starts for the selected cell.

C#
public event System.Windows.Forms.DataGridViewCellCancelEventHandler CellBeginEdit;
C#
public event System.Windows.Forms.DataGridViewCellCancelEventHandler? CellBeginEdit;

Event Type

Examples

The following code example illustrates how to handle this event to reflect that the current DataGridViewCell is being edited. In this example, the Text property of the containing Form is set to reflect which cell is being edited. To run this example, paste the code into a form that contains a DataGridView named dataGridView1, and ensure all events are associated with their event handlers.

C#
private void dataGridView1_CellBeginEdit(object sender,
    DataGridViewCellCancelEventArgs e)
{
    string msg = String.Format("Editing Cell at ({0}, {1})",
        e.ColumnIndex, e.RowIndex);
    this.Text = msg;
}

private void dataGridView1_CellEndEdit(object sender,
    DataGridViewCellEventArgs e)
{
    string msg = String.Format("Finished Editing Cell at ({0}, {1})",
        e.ColumnIndex, e.RowIndex);
    this.Text = msg;
}

Remarks

For more information about how to handle events, see Handling and Raising Events.

Applies to

Product Versions
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also