Formatting StiText using dynamic data
Posted: Wed Apr 13, 2011 7:50 am
Hi,
I've written a wrapper in C# that loads a template report and then dynamically adds the data bands into the report.
My problem is that I am having trouble changing the brush colour to red for negative numbers. After I compile my report I add the following line to listen for the event:
report.CompiledReport.GetComponents()["Total"].BeforePrint += new EventHandler(this.DataDataSource1_Column_Conditions);
And then I process the event with the following code:
if ((((decimal)(StiReport.ChangeType(report.DataSources[0][sender.ToString()], typeof(decimal), true))) <= 0m))
{
((Stimulsoft.Report.Components.IStiTextBrush)(sender)).TextBrush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.Red);
((Stimulsoft.Report.Components.IStiBrush)(sender)).Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.Transparent);
((Stimulsoft.Report.Components.IStiFont)(sender)).Font = new System.Drawing.Font("Arial", 8F);
((Stimulsoft.Report.Components.StiComponent)(sender)).Enabled = true;
return;
}
The problem with this code is that it is only ever looking at the first row of data.
Any ideas or help on where am I going wrong?
Chris L
I've written a wrapper in C# that loads a template report and then dynamically adds the data bands into the report.
My problem is that I am having trouble changing the brush colour to red for negative numbers. After I compile my report I add the following line to listen for the event:
report.CompiledReport.GetComponents()["Total"].BeforePrint += new EventHandler(this.DataDataSource1_Column_Conditions);
And then I process the event with the following code:
if ((((decimal)(StiReport.ChangeType(report.DataSources[0][sender.ToString()], typeof(decimal), true))) <= 0m))
{
((Stimulsoft.Report.Components.IStiTextBrush)(sender)).TextBrush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.Red);
((Stimulsoft.Report.Components.IStiBrush)(sender)).Brush = new Stimulsoft.Base.Drawing.StiSolidBrush(System.Drawing.Color.Transparent);
((Stimulsoft.Report.Components.IStiFont)(sender)).Font = new System.Drawing.Font("Arial", 8F);
((Stimulsoft.Report.Components.StiComponent)(sender)).Enabled = true;
return;
}
The problem with this code is that it is only ever looking at the first row of data.
Any ideas or help on where am I going wrong?
Chris L