Click here to Skip to main content
15,860,972 members
Articles / Programming Languages / C#
Article

Rows Coloring in Crystal Reports

Rate me:
Please Sign up or sign in to vote.
3.88/5 (5 votes)
24 Feb 2008CPOL1 min read 44.6K   18   3
The article intends to show how to color rows in Crystal Reports depending on the business requirement which might arise

Introduction

During development there are chances that a person might encounter a problem of how to display colored rows in a crystal report, where colors themselves might actually represent something. I encountered this problem and was searching for solutions on the web but couldn’t find any. But in the end I cracked it, so I thought why not share it, so here goes. <o:p>

CRTutorial2.jpg


Details

Shown above is an extraction from the report I was creating. To achieve such functionality you’d have to open the Section Expert from the Details Section. Then select the Color tab and then click on the formula button.

CRTutorial3.jpg

This would open the Formula Editor where you can specify the different conditions on to which the appropriate colors can be displayed. For more details on the available colors expand the Functions tree item in the Functions Tree, and look for the Color Constants tree item. Expanding it would reveal the list of supported colors.

CRTutorial1.jpg

<o:p>

<o:p>

The formula that I have used here is as follows:<o:p>

if({AgingList.Total}>({AgingList.Principal}+{AgingList.Profit})) then Crgreen
else if({AgingList.Total}=0) then Crblue
else if({AgingList.Total}<({AgingList.Principal}+{AgingList.Profit})) then CrYellow
else NoColor

(Note: Don’t forget to assign the NoColor color to the rows which do not fit to the requirements for the coloured lines else they may defaultly be displayed as blacked out.)

Save the report and Play. If all conditions satisfied you should be able to see the desired result.<o:p>

<o:p>

Conclusion

This procedure should solve the problem of colored rows where ever intended in the report.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader CodeAesthetics
Pakistan Pakistan
A small time software engineer with big time ideas. Helping others get their ideas on the road so that some day I can fuel mine.

Wannabe Software Designer, work in progress, obsessed with Aesthetics especially of Engineering.

Having spent over 8 years writing software professionally I have, atleast tried to help, many companies build and improve on their existing business implementations. Having gone solo for a few years now, I am constantly on the look out for people with problems looking for someone to help solve them whilst building a strong lasting professional relationship in the process.

Comments and Discussions

 
Generalthanks Pin
anis_sg7-Apr-14 12:35
anis_sg7-Apr-14 12:35 
GeneralMy vote of 1 Pin
Daniel Nutu1-Feb-09 10:48
Daniel Nutu1-Feb-09 10:48 
Generalchange the font style at run time Pin
da_dhanaraj3-Nov-08 9:28
da_dhanaraj3-Nov-08 9:28 
hi,
Please clarify my doubts. I have certain column fields in my crystal report and also certain row fields and group headers in my crystal report. I don't know exactly how many columns and rows are coming in the crystal report, because they are depends upon the database. In my problem is i want to change their color and font at run time through C#.net windows application.. how can i solve this.. give some guidance about this


regards

dhanaraj

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.