We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

checkboxes - how do I change the value?

I have a column set as a checkbox, yet I can't change the value by clicking the checkbox.. I can change the CellValue in code, and it sticks, but it won't update the checkbox in the field, nor can I click the checkbox itself (well, I can, it just doesn't toggle the value).

4 Replies

AD Administrator Syncfusion Team June 10, 2003 02:24 PM UTC

Also make sure you have set teh checkboxoptions. This object tells the grid what to consider true and what to consider false for this cell.
this.gridControl1[1,1].CellType = "CheckBox";

this.gridControl1[1,1].CheckBoxOptions = new GridCheckBoxCellInfo("1", "0", "", false);

this.gridControl1[1,1].Text = "1";


this.gridControl1[3,1].CellType = "CheckBox";
this.gridControl1[3,1].CheckBoxOptions = new GridCheckBoxCellInfo("True", "False", "", false);

this.gridControl1[3,1].Text = "True";

If this is not the problem, is this a GriddataBoundGrid or a GridControl you are using?


TL Tom Langer June 10, 2003 04:51 PM UTC

Thanks, this will do the trick. I'm using the plain ol grid.


TL Tom Langer June 10, 2003 05:02 PM UTC

I spoke too soon... I tried out the code and a get an error: An unhandled exception of type 'System.FormatException' occurred in system.dll Additional information: 0 is not a valid value for Boolean. Here's the code I'm using: grdLineItems(tmpRow, 1).CellType = "CheckBox" grdLineItems(tmpRow, 1).CheckBoxOptions = New GridCheckBoxCellInfo("1", "0", "", True) grdLineItems(tmpRow, 1).Text = "0" looks the same as yours.. So I'm guessing some other problem? Any properties in the grid that prevent it from working? It's not readonly, I also know this because I can type free text in other cells.


TL Tom Langer June 10, 2003 05:07 PM UTC

Problem resolved.. The above code DOES work, I just had the value type of the column set to boolean, I set it to string and it's fine now.

Loader.
Live Chat Icon For mobile
Up arrow icon