Print Page | Close Window

Different look of even/odd rows in detail section

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=2074
Printed Date: 29 Apr 2024 at 8:55am


Topic: Different look of even/odd rows in detail section
Posted By: Dawton
Subject: Different look of even/odd rows in detail section
Date Posted: 18 Jan 2008 at 2:56am
Hello,
please does anyone know how to make different look of even/odd rows in detail section? I want to swap 2 background colours - or display/hide a colour rectangle to have "color/white" look.
Thanks for hints
*D.



Replies:
Posted By: Lugh
Date Posted: 18 Jan 2008 at 5:24am
Go to the Section Expert.
Go to the section you want to color (presumably Details).
Go to the Color tab on the right-hand side.
Check Background Color on.
Click on the "x-2" button next to the color selector.

The formula should look like:

If RecordNumber mod 2 = 0 Then
crSilver
Else
crWhite

(Obviously, replace the colors with whatever you like.)

The modulo operator returns the remainder when the first number is divided by the second number.  So, "RecordNumber mod 2" returns 0 on even records, and 1 on odd records.

This can be expanded to similar effects.  So, to get a "greenbar" effect, in which the color changes for groups of five records, use:

If RecordNumber mod 10 >= 5 Then
crGreen
Else
crWhite




Posted By: Dawton
Date Posted: 05 Feb 2008 at 11:46pm
This works perfect!
Now I'm trying to find out how to change rectangle fill-colour depending on row number. I cannot find that magic button "x-2" in rectangle properties.
Am I blind? Or is there any chance to do it?
Thanks


Posted By: BrianBischof
Date Posted: 06 Feb 2008 at 12:13am
True, the rectange doesn't have a formula button for the color (or any of the other properties). One trick would be to use an empty textbox as the rectange. Set the background color using a formula, and to make sure that it prints under the other report objects, set it to Move > To Back. 

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>



Print Page | Close Window