SIGN UP MEMBER LOGIN:    
ARTICLE

Alternate Row Color in Crystal Report

Posted by Suparba Panda Articles | Crystal Reports C# June 07, 2005
This article shows how to develop reports with alternating row colors.
Reader Level:

Most of the time while developing reports people wonder how to have alternating row colors in the report like below.

Customer Name Address City State Zip
Suparba panda 123 olive rd St Louis MO  54678
John Doe 456 Tree drive Raleigh NC 14676
Jane Doe 768 Hudson rd Atlanta GA 76555

There is a cool trick to it.

Go to the format section of the Details. Click the Color Tab. Then click the button next to the Background Color CheckBox..

CR1.gif

In the formula editor of background color, type the following:

if RecordNumber mod 2 = 0 then crSilver else crNoColor.

CR2.gif

Save and close the editor.

And now when you run the report you will see alternate colors of silver and white in the details section.

Conclusion

In this article you learnt how to have alternating colors in the report detail section.

Login to add your contents and source code to this article
share this article :
post comment
 

thats excellent thanks for the idea..anyway can you give me an idea to change color of a particular record in details crytal report

Posted by Joseph Thomas Oct 29, 2011

If you are working with Gridview, you can alternate colors with AlternatingRowStyle tag. <RowStyle BackColor="#F7F6F3" ForeColor="#003333" /> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" /> <AlternatingRowStyle BackColor="White" ForeColor="#284775" />

Posted by Allen Licha May 05, 2011

How can I do this since VB.net 2008?

Posted by Jonatan Rangel May 05, 2011

I have a crystal report that contains alternating row colors. I developed it the same way as you discussed here but i have a problem. When i run the report, the rows that have silver background is coming out of table boundries. I mean the shadow background is coming out of table boundries. Do you know why?

Posted by Ahmed Youssef Nov 09, 2010

When we represent some data in a grid view we usually prefer to set alternative row color.For this we can use two css classes with different background colors or inline styles. What we need to do is that while constructing the grid by looping through data set, we can check the loop count is odd or even and then attach an alternative class or inline CSS accordingly.
 
Suppose we need two alternative colors '#ffffff' and '#dedede' .
 
Using jQuery we can do this very easily.
 
 jQuery provides :even and :odd  selectors through which we can select odd and even element and set background color.

Posted by eliza sahoo Mar 18, 2010
Nevron Gauge for SharePoint
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Team Foundation Server Hosting
Become a Sponsor