Page 1 of 1
How to access components?
Posted: Sun Jul 09, 2006 6:00 pm
by fphealthcare
I have created a report with the layout I want, with no data.
I need to be able to change the values of the components. In particular I need to be able to change the following.
1. The text value of a text box - I have many text boxes in the report, all of which need to have the text value to be displayed changed at runtime using code (C#).
2. The (source) image in an image box - I have added some images, the source (file) of the image need to be loaded at runtime in code. The image will be a complicated chart/graph which needs to be generated first, then saved as a picture, then loaded into the report.
Can these things be done?
Thanks
How to access components?
Posted: Mon Jul 10, 2006 4:52 am
by Edward
fphealthcare wrote:2. The (source) image in an image box - I have added some images, the source (file) of the image need to be loaded at runtime in code. The image will be a complicated chart/graph which needs to be generated first, then saved as a picture, then loaded into the report.
Can these things be done?
Thanks
There are two ways of changing images in the report .
The first way - the report is not compiled
The second way - the report is compiled of loaded from asembly
The first way.
Find the component with the image in the report:
Code: Select all
StiImage image = report.GetComponents()["image1"] as StiImage;
Change the image:
In this way your image will be converted to the code and then your report will be compiled and run.
The second way.
Compile the report:
Find the component:
Code: Select all
StiImage image = report.GetComponents()["image1"] as StiImage;
Assign the image:
fphealthcare wrote:I have created a report with the layout I want, with no data.
I need to be able to change the values of the components. In particular I need to be able to change the following.
1. The text value of a text box - I have many text boxes in the report, all of which need to have the text value to be displayed changed at runtime using code (C#).
To assign value to StiText component text1 in runtime please use following code
Code: Select all
text1.Text.Value = "value of text component"
Thanks!
How to access components?
Posted: Thu Jul 13, 2006 5:31 pm
by fphealthcare
There are two ways of changing images in the report .
The first way - the report is not compiled
The second way - the report is compiled of loaded from asembly
The first way.
Find the component with the image in the report:
Code:
StiImage image = report.GetComponents()["image1"] as StiImage;
Change the image:
Code:
Image.Image = myImage;
In this way your image will be converted to the code and then your report will be compiled and run.
The second way.
Compile the report:
Code:
report.Compile();
Find the component:
Code:
StiImage image = report.GetComponents()["image1"] as StiImage;
Assign the image:
Code:
image.ImageToDraw = myImage;
Thanks for the reply. The first method worked well, and I can now dynamically change the image. Great! The 2nd method compiles and runs, but still shows the original image. How are the 2 methods different?
To assign value to StiText component text1 in runtime please use following code
Code:
text1.Text.Value = "value of text component"
This worked perfectly as well.
Thanks a lot for your help so far. My report is beginning to look like a report!
How to access components?
Posted: Fri Jul 14, 2006 3:15 am
by Edward
Please try to use StiImage.Image property in the second method.
Property ImageToDraw can be used in case the Report is already compiled and rendered and you want to change image of this Report.
Thanks!