In a GridDataBoundGrid, in order to set cell specific backcolors, then you must handle the PrepareViewStyleInfo event and dynamically provide the color based on the e.RowIndex and e.ColIndex values passed in, and you have to keep providing this backcolor as long as you want to see it. See this KB. http://64.78.18.34/Support/article.aspx?id=560
Here are two eventhandlers that I think does what you described for a single cell.
private int colorRow = -2;
private int colorCol = -2;
private void gridDataBoundGrid1_CurrentCellAcceptedChanges(object sender, CancelEventArgs e)
{
int tempRow = this.colorRow;
int tempCol = this.colorCol;
this.colorRow = -2;
this.colorRow = -2;
if(tempRow > -2)
{
//repaint the old one so color goes away
this.gridDataBoundGrid1.RefreshRange(GridRangeInfo.Cell(tempRow, tempCol));
}
GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
this.colorCol = cc.ColIndex;
this.colorRow = cc.RowIndex;
//paint the new one
this.gridDataBoundGrid1.RefreshRange(GridRangeInfo.Cell(this.colorRow, this.colorCol));
}
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if(e.ColIndex == this.colorCol && e.RowIndex == this.colorRow)
{
e.Style.BackColor = Color.Red;
}
}