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

Row Color

Hi I have a data bound grid and I set row colors depending on the value of one of the cells. The problem is when I click into one of the cells for example a date cell of the grid (CellValueType = typeof(System.DateTime)) with row color red, the background of the date cell is also red. I want the row to remain red, but when I click on any cell and the cell starts displaying/activates the cell control, I want to cell to be white background. How do I do this? Thanks!

1 Reply

AD Administrator Syncfusion Team September 22, 2004 05:13 PM UTC

In PrepareViewStyleInfo (which you might be using to set the row color), you can check for CurrentCell.IsEditing, and set the BackColor accordingly.
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	if(cc.ColIndex == e.ColIndex && cc.RowIndex == e.RowIndex && cc.IsEditing)
		e.Style.BackColor = Color.White;
	else if(cc.ColIndex > 0 && cc.RowIndex == e.RowIndex)
		e.Style.BackColor = Color.Red;
}

Loader.
Live Chat Icon For mobile
Up arrow icon