Page 1 of 1

Reading content of StiText during DataBand.AfterPrint Event

Posted: Thu Dec 01, 2016 8:23 am
by Prandl33
Hello,
I tried to get the content of StiText component in the DataBand.AfterPrint Event.
Here the codesnipes what I used:

StiReport report = new StiReport();
LoadReport(report);
data = Utils.GetData();
report.RegData("Daten", data);
report.Compile();
StiDataBand dataBand = (StiDataBand) report.CompiledReport.GetComponents()["DataBand"];
dataBand.AfterPrint += dataBand_AfterPrint;
report.ShowWithWpf();

Here the Methode for the event:

void dataBand_AfterPrint(object sender, EventArgs e) {
StiDataBand dataBand = (StiDataBand) sender;
// I have to read a StiText component, its content is a path for images
string imagePath = (dataBand.GetComponents()["MyPicturePath"] as StiText).Text.Value;

// searching ImageObject in DataBand
StiImage stiImage = (StiImage) dataBand.GetComponents()["MyPicture"];
System.Drawing.Image image = System.Drawing.Image.FromFile(data.ElementAt(index).BildPfad);
// make picture small
System.Drawing.Image smallImage = getSmallPicture(image);
stiImage.Image = smallImage ;
}

The problem is, that the imagePath (Text.Value) is always empty!

Re: Reading content of StiText during DataBand.AfterPrint Ev

Posted: Sun Dec 04, 2016 7:08 pm
by Alex K.
Hello,

In this case, you get the value from the report template.
Please try to use the following code:

Code: Select all

object renderedText;
...
report.Compile();
var dataBand = report.CompiledReport.GetComponentByName("DataBand1") as StiDataBand;
var stiText = report.CompiledReport.GetComponentByName("Text1") as StiText;
stiText.GetTag += StiText_GetTag;
dataBand.AfterPrint += DataBand_AfterPrint;
...
private void DataBand_AfterPrint(object sender, EventArgs e)
{
    // I have to read a StiText component, its content is a path for images
    string imagePath = (renderedText as StiText).Text;
    ...
}
Thank you.

Re: Reading content of StiText during DataBand.AfterPrint Ev

Posted: Wed Dec 07, 2016 3:27 pm
by Prandl33
Hello Aleksey!
Sorry but I don't understand the following codeparts of your answer.
stiText.GetTag += StiText_GetTag; ... where I do need this
string imagePath = (renderedText as StiText).Text; ... this don't work, I beleave

You might have an example for me, where reading StiText content during rendering?
Thank you

Re: Reading content of StiText during DataBand.AfterPrint Ev

Posted: Thu Dec 08, 2016 9:59 pm
by Alex K.
Hello,

This event needed for getting an object from the rendered report, not from the template.
Please send us a simple project which reproduces the issue for analysis.

Thank you.

Re: Reading content of StiText during DataBand.AfterPrint Ev

Posted: Fri Dec 09, 2016 6:19 am
by Prandl33
Hello Aleksey,
this was the missing link :P

Code: Select all

         void stiText_GetTag(object sender, StiValueEventArgs e) {
             renderText = sender;
         }
Now it is working fine.
Thank you

Re: Reading content of StiText during DataBand.AfterPrint Ev

Posted: Fri Dec 09, 2016 6:25 am
by Alex K.
Hello

We are always glad to help you!
Please let us know if you need any additional help.

Thank you.