Reading content of StiText during DataBand.AfterPrint Event
Posted: Thu Dec 01, 2016 8:23 am
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!
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!