in my sample report i implemented a postprocessing step after the report is rendered. In that step i assign a random textbrush to all StiText components as follows:
Code: Select all
report.Compile();
report.CompiledReport.EndRender += DoPostProcessing;
Code: Select all
private void DoPostProcessing(object sender, EventArgs eventArgs)
{
StiReport report = sender as StiReport;
if (!ReferenceEquals(report, null))
{
Random r = new Random();
foreach (StiPage renderedPage in report.RenderedPages.Items)
{
StiComponentsCollection componentsCollection = renderedPage.GetComponents();
foreach (var component in componentsCollection)
{
StiText textComponent = component as StiText;
if (!ReferenceEquals(textComponent, null))
{
textComponent.ComponentGuid = Guid.NewGuid().ToString();
textComponent.TextBrush = new StiSolidBrush(Color.FromArgb(r.Next(1, 256), r.Next(1, 256), r.Next(1, 256)));
textComponent.Click += TextComponentOnClick;
}
}
}
}
}
But i also like to register a click event to every StiText component. The handler method should output the name, value and ComponentGuid of every single text component. But that does not work. After clicking on a text component no value is shown and the handler method is called for every component with same name.
Code: Select all
private void TextComponentOnClick(object sender, EventArgs eventArgs)
{
StiText text = sender as StiText;
if (!ReferenceEquals(text, null))
{
Trace.WriteLine(string.Format("Click on {0} ({2}). Value: {1}", text.Name, text.TextValue, text.ComponentGuid));
}
}
I attached sample project as zip file.
Thanks
Thorsten Pontow