ARTICLE

Alternate Row Color in Crystal Report using VB.NET

Posted by Suparba Panda Articles | Visual Basic 2010 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..
 

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

if RecordNumber mod 2 = 0 then crSilver else crNoColor

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.

NOTE: THIS ARTICLE IS CONVERTED FROM C# TO VB.NET USING A CONVERSION TOOL. ORIGINAL ARTICLE CAN BE FOUND ON C# CORNER (WWW.C-SHARPCORNER.COM).

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

Hi, I have an VB.net 2008 application and I use reports made in Crystal Reports. I want to know how I can alternate row color in a Crystal Report using vb code. Does anyone can help me? My intention is to alternate row color selected by the user on runtime, so I need to know how to codify this. In the Crystal Report you can code this in the Details Section: "If RecordNumber mod 2 = 0 then crSilver else crNoColor" But this is hard code...I want to know how to set this dynamically since my VB application. I'd thank you any advice.

Posted by Jonatan Rangel May 06, 2011
6 Months Free & No Setup Fees ASP.NET Hosting!
Become a Sponsor
PREMIUM SPONSORS
  • The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Team Foundation Server Hosting
Become a Sponsor