A question about variables

Stimulsoft Reports.NET discussion
Post Reply
incognito_gbg
Posts: 23
Joined: Wed May 30, 2007 4:15 am

A question about variables

Post by incognito_gbg »

In my report, I have a databand where rows added from an XML-file I bind with the report in my C#-application. Is there anyway that I after creating the report can loop through all the rows in the databand and set a variable for each row based on conditions in my application?

For example: If I display the items from the XML-file in my application and have checkboxes for each row, then I in my stimulreport want a string-variable that has the value "checked" if the checkbox is checked, or the value "" if it isnt.

pseudo-code

foreach (row in databand1 in my stimulreport)
{
if (c#-rowCheckBox is checked)
row["variable"] = "checked";
}

Something like that. Is that possible?
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

A question about variables

Post by Edward »

When the report is rendered it is represented as a collection of Pages and each page contains components with the same names as in the report template. So if your template contains Text1 component, then that component will be spread with the Name Text1. So after rendering you can loop through each Page and access these components via their coordinates or via report.RenderedPages[index_of_the_page].GetComponents() property. GetComponents() will return all Components for the specific page. The method report.GetComponents() after rendering will return all rendered components from all pages at once in the order how they was rendered.

Access to this rendered components you can get after calling Render() method of the report.

If you need to set variables before rendering the report then you can define your own method in your Application. Then you can call this method from the report in the BeforePrintEvent of the DataBand to set a variable or a checkbox of the report properly. How to define a custom methods in the StimulRport.Net you can see here:
http://www.stimulsoft.com/livedemos/Rep ... ction.html
The rows' number you may obtain via DataSource.Pos property of the datasource of the Databand on which your checkboxes are placed.

If none of this suggestions helped then please describe your task in more details.

Thank you.
Post Reply