To reproduce:
- Bind the grid to a self reference data, it should contain nullable bool value as well.
- Add checkbox column:
GridViewCheckBoxColumn chkBoxColumn = new GridViewCheckBoxColumn();
chkBoxColumn.EnableHeaderCheckBox = true;
chkBoxColumn.ThreeState = true;
chkBoxColumn.EditMode = EditMode.OnValueChange;
- Start and uncheck and check one of the cells (in a data row)
Workaround:
public class MyGridCheckBoxHeaderCellElement : GridCheckBoxHeaderCellElement
{
public MyGridCheckBoxHeaderCellElement(GridViewColumn column, GridRowElement row) : base(column,row)
{
}
protected override bool SetCheckBoxState()
{
bool hasNullValue = false;
foreach (GridViewRowInfo row in this.ViewInfo.Rows)
{
object cellValue = row.Cells[this.ColumnIndex].Value;
if (cellValue == null)
{
hasNullValue = true;
}
}
if (!hasNullValue)
{
return base.SetCheckBoxState();
}
SetCheckBoxState(ToggleState.Indeterminate);
return false;
}
}