Hi,
Have you set the true value and false value of the checkboxColumn?
If not, the default checkboxcell will be cheked when you set the value to true or 1.
You can try the following code:
DataGridViewCheckBoxColumn chk = new DataGridViewCheckBoxColumn();
chk.Name = "Check";
chk.HeaderText = "Test";
dataGridView1.Columns.Add(chk);
dataGridView1.Rows[0].Cells["Check"].Value = 1;
dataGridView1.Rows[1].Cells["Check"].Value = true;
DataGridViewCheckBoxColumn chk02 = new DataGridViewCheckBoxColumn();
chk02.Name = "Check02";
chk02.HeaderText = "Test02";
chk02.TrueValue = "aa";
chk02.FalseValue = "bb";
dataGridView1.Columns.Add(chk02);
dataGridView1.Rows[0].Cells["Check02"].Value = "aa";
dataGridView1.Rows[1].Cells["Check02"].Value = "bb";
By the way, the checked state of unbound checkboxcells will lose when you sort the column. You can use a dictionary object to store the checked state.
29. How do I show unbound data along with bound data?
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/a44622c0-74e1-463b-97b9-27b87513747e#faq29
More information:
DataGridViewCheckBoxColumn.FalseValue Property
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcheckboxcolumn.falsevalue.aspx
DataGridViewCheckBoxColumn.TrueValue Property
http://msdn.microsoft.com/en-us/library/system.windows.forms.datagridviewcheckboxcolumn.truevalue.aspx
Best regards,
Ling Wang
Please remember to click “Mark as Answer�on the post that helps you, and to click “Unmark as Answer�if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.