reading list variables from code

Stimulsoft Reports.NET discussion
Post Reply
Jozef Balga
Posts: 56
Joined: Fri May 27, 2011 8:33 am
Location: Bratislava, Slovakia

reading list variables from code

Post by Jozef Balga »

Hi!
I am currently working on reports which use parameters set by external C# application, but first I need to get these parameters, their types and values. I use the following code

Code: Select all

Console.WriteLine("name " + report.Dictionary.Variables[param.name].Name);
Console.WriteLine("type " + report.Dictionary.Variables[param.name].Type);
Console.WriteLine("obj  " + report.Dictionary.Variables[param.name].ValueObject);
This works fine for primitive types but I am experiencing problems when reading list types (LongList, StringList), the ValueObject is null even when I set items in the Designer for that variable. How can I retrieve the items defined for these lists?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

reading list variables from code

Post by Alex K. »

Hello,

You can use the following code:

Code: Select all

report.Dictionary.Variables["VariableName"].DialogInfo.GetDialogInfoItems(typeof(LongList));
Thank you.
Jozef Balga
Posts: 56
Joined: Fri May 27, 2011 8:33 am
Location: Bratislava, Slovakia

reading list variables from code

Post by Jozef Balga »

Thank you for the solution, it works perfectly.
Andrew
Posts: 4109
Joined: Fri Jun 09, 2006 3:58 am

reading list variables from code

Post by Andrew »

Great!

Have a nice day!
Jozef Balga
Posts: 56
Joined: Fri May 27, 2011 8:33 am
Location: Bratislava, Slovakia

reading list variables from code

Post by Jozef Balga »

One more question: is it possible to get the variable list items defined as data columns? I explain: I have to do some filtering in SQL queries using the IN operator, so I need the values which can be passed to the query. The problem is, I need to get these items and then re-set them (removing some of them) before rendering the report. Thank you for your answer.

Jozef
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

reading list variables from code

Post by Alex K. »

Hello,

As a way, you can use the following code in Rendering event of report:

Code: Select all

List list = null;
StiVariable variable = this.Dictionary.Variables["Variable1"];
           
list = variable.DialogInfo.GetDialogInfoItems(typeof(IntList));
Thank you.
Post Reply