开发者

how to paint line in crystalReport by value

开发者 https://www.devze.com 2023-01-17 22:34 出处:网络
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

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


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消