The WinCheckBox editor (which is the control underneath the CheckBoxViewer) expects a boolean value, not an integer, so it throws an exception that is swallowed by the grid, and the grid displays a red X instead. What you need to do is handle the SettingControlValue event on the CheckBoxViewer, and convert the int value to boolean value (or a CheckState value to be precise) so the viewer can display itself correctly.
e.g.:
private void Form1_Load( object sender, EventArgs e )
{
gridControl1.Columns[ IntColumn ].CellViewerManager = new CheckBoxViewer();
gridControl1.Columns[ IntColumn ].CellViewerManager.SettingControlValue += new CellViewerEventHandler(CellViewerManager_SettingControlValue);
}
void CellViewerManager_SettingControlValue( object sender, CellViewerEventArgs e )
{
if( ( int )e.Cell.Value == 0 )
{
( ( WinCheckBox )e.Control ).CheckState = CheckState.Unchecked;
}
else if( ( int )e.Cell.Value == 1 )
{
( ( WinCheckBox )e.Control ).CheckState = CheckState.Checked;
}
else
{
( ( WinCheckBox )e.Control ).CheckState = CheckState.Indeterminate;
}
}
Imported from legacy forums. Posted by André (had 2051 views)