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.
Unfortunately, activation email could not send to your email. Please try again.

Alternate row styles

Thread ID:





63977 Jul 12,2007 02:52 AM Jul 13,2007 07:18 PM Windows Forms 3
Tags: GridControl
Lucia Diaconu
Asked On July 12, 2007 02:52 AM

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

haneefm [Syncfusion]
Replied On July 12, 2007 11:06 AM

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.

Best regards,

Replied On July 13, 2007 10:44 AM

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?

haneefm [Syncfusion]
Replied On July 13, 2007 07:18 PM

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,


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.