To reproduce:
1. Add text box and check box column to the grid. Add a filter descriptor to the text box column
2. Bind it to a DataTable with some data
3. Clear the columns
4. Add the columns once again => the exception will be thrown
Workaround.
1. Create the following cell element:
class MyHeaderCell : GridCheckBoxHeaderCellElement
{
public MyHeaderCell(GridViewColumn column, GridRowElement row)
: base(column, row)
{
}
protected override bool SetCheckBoxState()
{
if (this.ColumnIndex == -1)
{
return false;
}
return base.SetCheckBoxState();
}
}
2. Subscribe to the grid's CreateCell event
3. Put the modified cell in action:
void radGridView_CreateCell(object sender, GridViewCreateCellEventArgs e)
{
if (e.CellType == typeof(GridCheckBoxHeaderCellElement))
{
e.CellType = typeof(MyHeaderCell);
}
}