Page 2 of 5

Re: Dynamically adding a subreport to a page

Posted: Wed Aug 07, 2013 8:13 am
by prajan
Hi,
I don't think I can use report.GetComponents() because I am not loading the report from a .mrt file.
In fact, if you look at the code in the attached page 'Default2.aspx' , you will know that the report is being dynamically 'created' in the page. In this case how do I calculate the sum of the group header band. Please let me know.
Thanks.

Re: Dynamically adding a subreport to a page

Posted: Wed Aug 07, 2013 11:15 am
by Alex K.
Hello,

In this case please try use the following code:

Code: Select all

YourNameTextComponent = new StiExpression("{Totals.Sum(GroupHeaderBand1, Products.UnitPrice)}");
Thank you.

Re: Dynamically adding a subreport to a page

Posted: Wed Aug 07, 2013 12:10 pm
by prajan
Hi,
Thanks a million !
That did help a lot.
I have 2 more questions:
- How do I disable a group header band based on the value of a field in the datasource
- How to I set the color and font of a text based on its value.( i.e based on whether it is positive or negative)

Thanks.

Re: Dynamically adding a subreport to a page

Posted: Thu Aug 08, 2013 1:19 pm
by Alex K.
Hello,

Sorry, maybe we did not exactly understand your question. Could you explain your issue in more details?

Thank you.

Re: Dynamically adding a subreport to a page

Posted: Thu Aug 08, 2013 1:23 pm
by HighAley
Hello.
prajan wrote:- How to I set the color and font of a text based on its value.( i.e based on whether it is positive or negative)
You should use conditions for changing color of the text. Please, watch next videos http://www.stimulsoft.com/en/videos?tags=conditions

Thank you.

Re: Dynamically adding a subreport to a page

Posted: Thu Aug 08, 2013 1:49 pm
by prajan
Hi,
Like I already said, this report is getting generated dynamically, so I cannot use the designer to set the conditions.
I need to know, how we can set conditions in C# code
First condition - I want to disable a group header band depending on the value of a field in the data source
Second condition - I want to know how we can set the color and font of a text based on its value.

Please let me know if I haven't been clear.

Thanks.

Re: Dynamically adding a subreport to a page

Posted: Mon Aug 12, 2013 10:08 am
by HighAley
Hello.

Here is a sample code how to add Conditions:

Code: Select all

            StiCondition highlightcond = new StiCondition();
            highlightcond.DataType = StiFilterDataType.Numeric;
            highlightcond.TextColor = Color.Red;
            highlightcond.Column = "Categories.CategoryID";
            highlightcond.Condition = StiFilterCondition.EqualTo;
            highlightcond.Value1 = "1";
            highlightcond.Font = new System.Drawing.Font("Calibri", 10F, System.Drawing.FontStyle.Bold);
            highlightcond.BackColor = Color.Beige;
            highlightcond.Enabled = true;
            headerText.Conditions.Add(highlightcond);
Thank you.

Re: Dynamically adding a subreport to a page

Posted: Fri Aug 16, 2013 6:03 am
by prajan
Hi,
Thanks a lot. That worked like a dream!

I have another query. I am unable to add vertical line primitives dynamically to the report using C#.
I tried as below, but the line is not seen in the report.

Code: Select all

StiVerticalLinePrimitive stiLine1 = new StiVerticalLinePrimitive();
        stiLine1.Top = 2;
        stiLine1.Height = 10;
        stiLine1.PrintOn = StiPrintOnType.AllPages;
        stiLine1.ShiftMode = StiShiftMode.IncreasingSize;
        stiLine1.Printable = true;
        stiLine1.Enabled = true;
        pnReportTitle.Components.Add(stiLine1);
In the above code, I have tried adding the vertical line to a panel.
Previously I tried adding it to a page as well as to a report title band.
In all cases the vertical line is not seen at all.

Any help would be highly appreciated.

Thanks

Re: Dynamically adding a subreport to a page

Posted: Fri Aug 16, 2013 2:56 pm
by HighAley
Hello.

Please, try to use Borders instead of the Line Primitives.

Thank you.

Re: Dynamically adding a subreport to a page

Posted: Mon Aug 19, 2013 4:23 am
by prajan
Hi,
I need to add line primitives only. I cannot use borders.
Can you please let me know how it is possible?

Thanks