To reproduce:
- Bind the grid and reset its data source in the CellValueChanged event handler.
- Start the application, click in a cell, delete the contents and right click a header cell.
- Exception is thrown.
Workaround:
class MyGridHeaderCellElement : GridHeaderCellElement
{
public MyGridHeaderCellElement(GridViewColumn col, GridRowElement row) : base(col, row)
{ }
protected override Type ThemeEffectiveType
{
get
{
return typeof(GridHeaderCellElement);
}
}
protected override void ShowContextMenu()
{
if (this.ViewTemplate != null)
{
base.ShowContextMenu();
}
}
}
private void RadGridView1_CreateCell(object sender, GridViewCreateCellEventArgs e)
{
if (e.CellType == typeof(GridHeaderCellElement))
{
e.CellType = typeof(MyGridHeaderCellElement);
}
}