Select Page
This entry has been published on 2013-04-19 and may be out of date.

Last Updated on 2013-04-19.

If you set a DataGridView’s property EditMode to EditOnEnter, it is hard to find a way to delete the whole row.

Workaround:

 
private void dataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex < 0)
            {
                dataGridView.EditMode = DataGridViewEditMode.EditOnKeystrokeOrF2;
                dataGridView.EndEdit();
            }
            else
            {
                if (dataGridView.EditMode != DataGridViewEditMode.EditOnEnter)
                {
                    dataGridView.EditMode = DataGridViewEditMode.EditOnEnter;
                    dataGridView.BeginEdit(false);
                }
            }
        }

Reference (VB code)