We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

Color another cell in PrepareViewStyleInfo event

Hi,
In a GridDataBoundGrid grid in a the PrepareViewStyleInfo event I can color the current cell:

e.Style.BackColor = Color.Red;

But I need to color another cell right there also. I know its row and column indexes.

I tried:
grid[iRow,iColumn].BackColor = Color.Red;
But it's not working.

Is it possible? How can you do it?

Thanks ahead,
Ronnie.

1 Reply

AD Administrator Syncfusion Team February 27, 2007 11:09 PM UTC

Hi Ronnie,

Try setting the RefreshCurrentCellBehavior property to RefreshRow and handle the PrepareViewStyleInfo event of the grid to set the backcolor of the current cell and it's right adjacent cell. Please try the attached sample and let me know if this helps.

this.grid.Model.Options.RefreshCurrentCellBehavior = GridRefreshCurrentCellBehavior.RefreshRow;

private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if( e.RowIndex > 0 && e.ColIndex > 0)
{
GridCurrentCell cc = (sender as GridDataBoundGrid).CurrentCell;
if( cc.RowIndex == e.RowIndex && (cc.ColIndex == e.ColIndex || cc.ColIndex + 1 == e.ColIndex ))
e.Style.BackColor = Color.Red;
}
}

Sample : GDBGBackColor.zip

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon