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?
-
- Posts: 33
- Joined: Sun Jul 02, 2006 6:06 pm
- Location: New Zealand
How to access components?
There are two ways of changing images in the report .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
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;
Code: Select all
Image.Image = myImage;
The second way.
Compile the report:
Code: Select all
report.Compile();
Code: Select all
StiImage image = report.GetComponents()["image1"] as StiImage;
Code: Select all
image.ImageToDraw = myImage;
To assign value to StiText component text1 in runtime please use following codefphealthcare 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#).
Code: Select all
text1.Text.Value = "value of text component"
-
- Posts: 33
- Joined: Sun Jul 02, 2006 6:06 pm
- Location: New Zealand
How to access components?
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?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;
This worked perfectly as well.To assign value to StiText component text1 in runtime please use following code
Code:
text1.Text.Value = "value of text component"
Thanks a lot for your help so far. My report is beginning to look like a report!
How to access components?
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!
Property ImageToDraw can be used in case the Report is already compiled and rendered and you want to change image of this Report.
Thanks!