Reading content of StiText during DataBand.AfterPrint Event

Stimulsoft Reports.WPF discussion
Post Reply
Prandl33
Posts: 40
Joined: Wed Nov 16, 2016 4:24 pm

Reading content of StiText during DataBand.AfterPrint Event

Post 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!
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Reading content of StiText during DataBand.AfterPrint Ev

Post 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.
Prandl33
Posts: 40
Joined: Wed Nov 16, 2016 4:24 pm

Re: Reading content of StiText during DataBand.AfterPrint Ev

Post 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
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Reading content of StiText during DataBand.AfterPrint Ev

Post 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.
Attachments
Capture.PNG
Capture.PNG (49.82 KiB) Viewed 3474 times
Prandl33
Posts: 40
Joined: Wed Nov 16, 2016 4:24 pm

Re: Reading content of StiText during DataBand.AfterPrint Ev

Post 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
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Reading content of StiText during DataBand.AfterPrint Ev

Post by Alex K. »

Hello

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

Thank you.
Post Reply