Page 1 of 1

Add Summary Functions in runtime

Posted: Tue Nov 22, 2016 2:53 pm
by jenny
Hello!
I have a .Net procedure where i add StiText Components to data column band in dynamic way like this:
dataCol = new StiText();
dataCol.GetValue += new Stimulsoft.Report.Events.StiGetValueEventHandler(
(sender, e) => { e.Value = p.GetValue(mainDataSource).ToString(); });
dataBand.Components.Add(dataCol);

I would like to add StiText Components with a summary function to a data footer band with code. I tried something like this

footerCol = new StiText();
footerCol .GetValue += new Stimulsoft.Report.Events.StiGetValueEventHandler(
(sender, e) => { e.Value = "#%#{Sum(GroupHeader,fieldname)}"});
footBand.Components.Add(footerCol );
However, this is not enough, as the function Sum is not recognised and report displays the exact text of Value.
How can i add summary functions in runtime?

Re: Add Summary Functions in runtime

Posted: Wed Nov 23, 2016 9:55 am
by Alex K.
Hello,

Please try to use the following code:

Code: Select all

var footerCol = new StiText();
footerCol.ClientRectangle = new Stimulsoft.Base.Drawing.RectangleD(0.2, 0, 8.4, 1);
footerCol.Text = new StiExpression("{Sum(DataCategories, Categories.CategoryID)}");
var footBand = report.GetComponentByName("FooterBand1") as StiFooterBand;
footBand.Components.Add(footerCol);
report.Compile();
Thank you.

Re: Add Summary Functions in runtime

Posted: Thu Nov 24, 2016 1:36 pm
by jenny
Thank you for your response!
Unfortunately this didn't work, as i would like to add a column in runtime.
I suppose this is the answer why viewtopic.php?f=13&t=54071

Re: Add Summary Functions in runtime

Posted: Fri Nov 25, 2016 8:11 am
by HighAley
Hello.

Yes, if you do this at runtime, you should use the Totals class.

Thank you.