Writing Code
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Writing Code
Message Icon Topic: Update object in each report row! Post Reply Post New Topic
Author Message
cuonghn8
Newbie
Newbie


Joined: 20 Jun 2012
Online Status: Offline
Posts: 3
Quote cuonghn8 Replybullet Topic: Update object in each report row!
    Posted: 20 Jun 2012 at 4:56pm
HI all,

I need to make a report where in each row of report I want to add a percent bar based on my data. Because I have not found any built-in report template for this, so I came up with my own solution:

I draw a box, fill it up with color, then in code I will set it width accordingly.

My problem now is how I can access BoxObject in each row of report. I tried
foreach (CrystalReportDataRowView r in reportDocument.Rows)

but no luck.

Can anyone help me out, please?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 21 Jun 2012 at 3:43am
Is there a bar in each row or are you trying to create a chart?  If it's a chart, take a look at the bar chart object that's native to Crystal.
 
-Dell
IP IP Logged
cuonghn8
Newbie
Newbie


Joined: 20 Jun 2012
Online Status: Offline
Posts: 3
Quote cuonghn8 Replybullet Posted: 21 Jun 2012 at 7:48pm
Hi, thank you for replying.

Yes, each row has a bar, then in code I want to access each bar object and set its width or something.

Is it possible?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 22 Jun 2012 at 3:45am
I don't know that you can do this with a box.  However, you could try this instead:
 
1.  Replace the box with a text object.
2.  Right-click on the object and select "Format Text...".
3.  Go to the Border tab.  Set the border to Single for each side and set the background color. Then click on OK.
4.  Right-click on the text object and select "Size and Position".
5.  Click on the formula button next to width.  Enter a formula that will set the width based on the data.
 
If you want to show a variable width bar that is within a box that is always the same size, you could either draw a box around the text object or overlay two text objects - one that has the border and is always the same size and one that has the background color and variable width.  Align the top and left of the two and put the border block behind the color block.
 
-Dell
IP IP Logged
cuonghn8
Newbie
Newbie


Joined: 20 Jun 2012
Online Status: Offline
Posts: 3
Quote cuonghn8 Replybullet Posted: 25 Jun 2012 at 10:58pm
Problem solved :)

By the way, you should've mentioned "Size and Position" option is available on full version of Crystal report(I was using Crystal Report for Visual Studio).

Otherwise Big thanks.
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.