Print Page | Close Window

Update object in each report row!

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Writing Code
Forum Discription: .NET programming API, report integration
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=16809
Printed Date: 03 May 2024 at 1:49am


Topic: Update object in each report row!
Posted By: cuonghn8
Subject: Update object in each report row!
Date 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?



Replies:
Posted By: hilfy
Date 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


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: cuonghn8
Date 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?


Posted By: hilfy
Date 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


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: cuonghn8
Date 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.



Print Page | Close Window