Ok, I did some testing with the window designer and found something strange in the code generator. So what I did in my testing,
First, I added a column of type DataGridViewCheckBoxColumn and populated the datagridview table with a data table. I added some entry with null values.
Now it worked fine and the data was displayed correctly, and also did not produce any errors. Then I changed the DefaultCellStyle property of this CheckedBoxColumn and removed the False value from the Nullvalue property and ran it again. Now the application shows this error.
I returned to this DefaultCellStyle property and returned False . then I started this project again. But still it showed me the same error.
So, we downloaded the Form.designer.cs file and checked the dataGridViewCellStyle1 object. where I found that the property is set to the string type value "False" instead of the boolean type False .
dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter; dataGridViewCellStyle1.NullValue = "False"; this.Column1.DefaultCellStyle = dataGridViewCellStyle1; this.Column1.HeaderText = "Check Box"; this.Column1.Name = "chkCol";
So, I updated this line as follows and started the project again. Now the error has disappeared.
dataGridViewCellStyle1.NullValue = false;
When I created this DataGridViewCheckBoxColumn , I found that no cell was created by default for the property of the cell property. So, by default, the Nullvalue property was Nullvalue to False . but after changing this property, the object was created and the property is set to a string type value.
UPDATED:. This problem can be solved by re-creating this column.
source share