Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically uncheck checkboxcolumn in datagridview

How can I programmatically uncheck all rows in a DataGridViewCheckboxColumn in a datagridview?

I can get the correct value of the checkbox using

(bool)row.Cells[CheckBoxColumn.Index].FormattedValue

but that's only a getter.

I have tried setting the value of the cell using

(bool)row.Cells[CheckBoxColumn.Index].value = false

but that doesn't affect the FormattedValue.

How can I solve this?

like image 371
Awesome Avatar asked Sep 17 '25 22:09

Awesome


1 Answers

You do sth. like:

(row.Cells[CheckBoxColumn.Index] as DataGridViewCheckBoxCell).value = false;

You just forgot to cast to the correct type, a generic DataGridViewCell doesn't know its value-type.

like image 82
basti Avatar answered Sep 19 '25 13:09

basti