The definition of cell.ReadOnly has no effect


I have a DataGridView, where I want to disable some cells/rows with setting ReadOnly = true.

What could be the reason that sometimes this has no effect and the cells/rows are still editable?

Are there other possibilities to prevent editing specific rows or cells? Is it possible to prevent clicking or entering a cell?

You could prevent editing with the CellBeginEdit event. If you dont want the cell to be edited, you can cancel the edit. For example, if you only want the first column to be editable, you can do this:

private void dataGridView1_CellBeginEdit(object sender,
   DataGridViewCellCancelEventArgs e)
   if (e.ColumnIndex != 0)
      e.Cancel = true;