Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataGridView: Disable Cell Editing on Click or Keystroke, Enable Cell Editing only on Double Click

I am display some data in DataGridiView.

By default cell edit is enabled on keystroke or on click, I want to disable it.

I want the cell value to be edited only on double click.

How do I achieve this?

like image 921
CST RAIZE Avatar asked Mar 13 '23 18:03

CST RAIZE


1 Answers

Set the EditMode property of your DataGridView to EditProgrammatically. This makes editing begins only when the BeginEdit method is called.

Then handle CellDoubleClick event and call BeginEdit.

private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
    dataGridView1.BeginEdit(true);
}
like image 66
Reza Aghaei Avatar answered Mar 17 '23 06:03

Reza Aghaei