How to disable editing mode on cells but checkbox column?

My flag column does not respond when a checkmark is checked, apparently it was set to read-only, so changing the state back to false will enable the checkmark again. However, this will turn the entire editing mode into true. I tried setting the edit mode programmatically by setting ReadOnly to false, but this will turn off the checkbox again.

How to disable editing mode for all cells except the checkbox column?

+4
source share
1 answer

You can prevent editing with the CellBeginEdit event if the cell is not in the right column. For example, if the checkbox is in the first column:

private void dataGridView1_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) { if (e.ColumnIndex != 0) e.Cancel = true; } 
+5
source

Source: https://habr.com/ru/post/1304863/


All Articles