How to set Report Variable from Visual Studio code?

Stimulsoft Reports.NET discussion
Post Reply
User avatar
jp2code
Posts: 20
Joined: Thu Feb 11, 2016 9:10 pm
Location: Longview, TX [USA]

How to set Report Variable from Visual Studio code?

Post by jp2code »

I've created a report file "D:\Sales\Report1.mrt" with multiple variables.
screenshot showing variables over on the RIGHT
screenshot showing variables over on the RIGHT
getgreenshot_org.jpg (373.7 KiB) Viewed 2340 times
How do I now go about setting one of these variables?

Code: Select all

public void ShowReport()
{
    using (var report = new StiReport())
    {
        report.Load(_reportPath);
        report.p_boolPrintAmounts = false; // this is wrong.
        report.Compile();
        report.Show();
    }
}
For example, how would I set the parameter `p_boolPrintAmounts` to false?

I have many variables that need to be set before compiling the report:

Code: Select all

private String _reportPath;

public Boolean DisplayAmountsTendered { get; set; }
public Boolean DisplayNegativeInvoicesOnly { get; set; }
public Boolean DisplayMargins { get; set; }
public Boolean DisplayMarkups { get; set; }
public Boolean DisplayProfits { get; set; }
public Boolean DisplayTaxCodesAndAmounts { get; set; }
public Boolean DisplayWebOrdersOnly { get; set; }
public Boolean DisplayZeroTaxInvoiceOnly { get; set; }
public Boolean FilterIsInclusive { get; set; }
public Boolean UseMarketCost { get; set; }
public Boolean UseMarkupCost { get; set; }
public DateTime FilterInvoiceDateBegin { get; set; }
public DateTime FilterInvoiceDateEnd { get; set; }
public ReportSortSequence ReportSort { get; set; }
public DisplayWhichCost WhichCost { get; set; }
public DisplayWhichFormat WhichFormat { get; set; }
public DisplayWhichInvoice WhichInvoice { get; set; }
public DisplayWhichSales WhichSales { get; set; }
public String FilterInvoiceNumberBegin { get; set; }
public String FilterInvoiceNumberEnd { get; set; }
public String OnlyDisplayTaxCode { get; set; }
~Joe
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How to set Report Variable from Visual Studio code?

Post by HighAley »

Hello.

There are two different ways to change variable value.

One is to do it before compilation and other one to change value after compilation:

Code: Select all

report.Dictionary.Variables["Variable1"].Value = yourCancatenatedString; 
report.Compile(); 
report["Variable2"] = yourCancatenatedString;
Thank you.
User avatar
jp2code
Posts: 20
Joined: Thu Feb 11, 2016 9:10 pm
Location: Longview, TX [USA]

Re: How to set Report Variable from Visual Studio code?

Post by jp2code »

Interesting. I did not realize the 2nd version (report["Variable2"] = yourCancatenatedString;) could only be done after a compile.

Thank you!
~Joe
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: How to set Report Variable from Visual Studio code?

Post by HighAley »

Hello.

We are always glad to help you.
Let us know if you need our help.

Thank you.
Post Reply