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

Alternate row styles

I could not find the way to define alternate row styles for the grid. Is this possible?

3 Replies

HA haneefm Syncfusion Team July 12, 2007 03:06 PM UTC

Hi Lucia,

Normally, we would recommend you handle PrepareViewStyleInfo to alternately color the rows in a grid. Below is the forum thread that shows this task.
http://www.syncfusion.com/support/Forums/message.aspx?&MessageID=59492

Best regards,
Haneef


LU Lucia July 13, 2007 02:44 PM UTC

Than you again, Haneef.

Your answer lead me to another solution that I think is better, since I was using the QueryCellInfo event anyway:
if (e.ColIndex == -1) // row style needed
{
if (e.RowIndex % 2 == 1) //odd row
{
e.Style.BackColor = myOddRowColor;
}
}

I like more this method because I have to set the style once per row and not once for each cell. Or is it not so?



HA haneefm Syncfusion Team July 13, 2007 11:18 PM UTC

Hi Lucia,

The QueryCellInfo is hit anytime the grid needs a cell style for any reason. So QueryCellInfo is hit prior to PrepareViewStyleInfo, and may be hit for other reasons than preparing the style for drawing. If you use code like grid[row, col], then QueryCellInfo is hit, but PrepareViewStyleInfo may not hit. So, if you are setting a style property that may be of use to you for something other than be drawn a certain way, then you should use QueryCellInfo to set the property dynamically.

Best regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon