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

Trying to change the cells back color

Hi I am trying to change the cell back color in CellDrawn Event using the following code. if(e.RowIndex > 0) { e.Style.BackColor = Color.Red; } else { e.Style.BackColor = Color.BurlyWood; } Its not changing the color any suggestion are appreciated Thanks Gulshan

2 Replies

Administrator June 8, 2004 08:50 PM UTC

The CellDrawn event occurs AFTER the cell is drawn. So, trying to set the backcolor there will not do anything. Instead, use the PrepareViewStyleInfo event, and set the bckColor there using similar code.

GK Gulshan Khera June 8, 2004 09:02 PM UTC

Got the point Thanks Clay >The CellDrawn event occurs AFTER the cell is drawn. So, trying to set the backcolor there will not do anything. > >Instead, use the PrepareViewStyleInfo event, and set the bckColor there using similar code.
Loader.
Live Chat Icon For mobile
Up arrow icon