开发者

How to disable edit mode on cells but checkbox column?

开发者 https://www.devze.com 2022-12-23 16:48 出处:网络
My checkbox column doesn\'t respond when ticked, apparently it was set to read only, so changing state back to false aga开发者_Go百科in will make it possible to tick. However, that will turn the whole

My checkbox column doesn't respond when ticked, apparently it was set to read only, so changing state back to false aga开发者_Go百科in will make it possible to tick. However, that will turn the whole edit mode to true. I tried to set edit mode to programatically while setting ReadOnly mode to false, but that will disable the checkbox back again.

How can I disable edit mode on all cells except checkbox column?


You could prevent editing with the CellBeginEdit event if the cell isn't 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;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消