views:

32

answers:

2

hi

i have my database that show by crystal report, it has field ID and Name.

i need that if the value of ID = 8 the line in crystal report will paint in red

and if ID=10 in green.

i use C# VS2008

thank's in advance

+2  A: 

Use formula for that line in your report. its so simple... you can write ur code as VB...

Dr TJ
you can put a line in ur report, then in properties and in right side of color or text color property (i think) there is a button to add your formula. so simple bind the color to ID's value...
Dr TJ
can i get any sample ?
Gold
the problem is that i have VS2010 installed on my PC and it doesn't support crystal report... but, let me do it in a virtual machine and send to you...
Dr TJ
+1  A: 

Ok... You forced me to install a windows XP in a virtual machine and VS 2008 on it to find this answer... ;)
anyway, this is the answer...
You should write this code where ever u wanna show that report:
First of all add this refrence to your code:

using CrystalDecisions.CrystalReports.Engine;

Then you can access your object (in our case its a LineObject) like so:


ReportDocument reportDoc = CrystalReport11;

//1- define a LineObject variable
LineObject myLine;

//Find the object in ReportObjects collection and cast it as LineObject
//and finally, set it to your variable
myLine = ((LineObject)reportDoc.ReportDefinition.ReportObjects["Line1"]);

//do your changes...
myLine.LineColor = Color.Red;

I've defined a ReportDocument in order to show you how to do it with dynamically loaded reports...
Good luck

Dr TJ
thank's for the help !
Gold
you are welcome
Dr TJ