Carlo577860

I have a bound datagridview with a two state checkbox column in it. Here is how I'm creating the column:

Code Snippet

using (DataGridViewCheckBoxColumn c = new DataGridViewCheckBoxColumn(false))
{
c.ThreeState = false;
c.TrueValue = true;
c.FalseValue = false;
c.HeaderText = "Uso Esclusivo";
c.DataPropertyName = "exclusiveUse";
c.Name = "exclusiveUse";
c.ValueType = typeof(bool);

dgvCatalogue.Columns.Remove("exclusiveUse");
dgvCatalogue.Columns.Add(c);
}


I'm saving it with the data access block of the enterprise library, but I receive a null value on the db (a mysql one) if I don't check the check box.
Anyway, I tried saving the bound dataset as xml and I see that the field bound to the checkbox is not displayed.
To better understand: if I check the box and then unckeck it, i get a 0 (false) value on the db. If I check it once, I get a 1 on the db. If I don't "touch" it, I get a null value. Even the db field default value of 0 doesn't work. How can I do thanks,

Carlo.



Re: Windows Forms Data Controls and Databinding Default DataGridViewCheckBox Value

Ken Tucker

I would assign the Cell a false value in the datagridview's defaultvaluesneeded event





Re: Windows Forms Data Controls and Databinding Default DataGridViewCheckBox Value

Carlo

thanks, problem resolved Smile