I have a simple grid that I bind a DataTable to. I have created an unbound CheckBox column as the first column. It seems to create and display OK. I can check/uncheck the column. I want to loop through the rows in the grid and check that cell to see if the checkbox is checked. I thought I could see if the Cell.Value was true. However, Cell.Value is always false for the cell that has the CheckBox. How can I test if the CheckBox is checked or not in a cell?
Here's how I set up the Checkbox column:
band.Columns.Add(CommentDialogConstants.CHECKBOXCOLUMN, string.Empty);band.Columns[CommentDialogConstants.CHECKBOXCOLUMN].DataType = typeof(bool);band.Columns[CommentDialogConstants.CHECKBOXCOLUMN].CellActivation = Activation.AllowEdit;band.Columns[CommentDialogConstants.CHECKBOXCOLUMN].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;band.Columns[CommentDialogConstants.CHECKBOXCOLUMN].Width = 25;band.Columns[CommentDialogConstants.CHECKBOXCOLUMN].Header.VisiblePosition = headerPosition++;band.Columns[CommentDialogConstants.CHECKBOXCOLUMN].Header.Fixed = true;band.Columns[CommentDialogConstants.CHECKBOXCOLUMN].Header.Appearance.TextHAlign = HAlign.Center;
In what event are you trying to examine the value of the cell?
My guess is that you are checking the cell that is still in edit mode before the change has been committed.
The Value of a cell does not get commmitted until the user leaves the cell by default - this depends on the UpdateMode property.
This probably seems a bit off for a TextBox cell, but if you think about a DateTime cell, it makes a lot of sense. If the user is typing into a DateTime cell, they could type the beginning of a date, like "1". "1" is not a valid date, so there's no way the control can update the Value of the cell, because "1" is not a valid DateTime.
So the grid does not attempt to update the Value until the user leaves the cell, at which time, he is presumably done editing and has entered a complete date.
So depending on what event you are using, you could call Update on the grid's ActiveRow to commit the change, or you could check the Text property of the cell and use boolean.Parse to convert it.