I cannot set GuidList type parameter on runtime

Stimulsoft Reports.NET discussion
Post Reply
ruen
Posts: 3
Joined: Fri Mar 15, 2024 12:25 pm

I cannot set GuidList type parameter on runtime

Post by ruen »

Hello,

I am currently working with a report that incorporates a variety of parameters. My objective is to execute the report with predefined values. While I am able to assign values to all parameter types without issue, I encounter difficulties specifically with the GuidList type.

Code: Select all

var stiVariable = stiReport.Dictionary.Variables[anyVariable];
For parameters of boolean, string, and Guid types, the assignment operates as expected:

Code: Select all

stiVariable.ValueObject = true/false;
stiVariable.ValueObject = "string";
stiVariable.ValueObject = new Guid(guidValue);
However, when attempting to assign a GuidList type as shown below:
stiVariable.ValueObject = new GuidList(new Guid(guidValue));

I've noticed that there is no implementation of any kind of list object in ValueObject's setter (StiVariable.cs => private void SetValue(object value))
The operation completes without throwing any exceptions, yet the stiVariable.ValueObject and Value properties remain null. This issue persists despite the necessity to run the report with multiple GUID selections.

Would you have any insights or suggestions to resolve this matter?

Thanks.
ruen
Posts: 3
Joined: Fri Mar 15, 2024 12:25 pm

Re: I cannot set GuidList type parameter on runtime

Post by ruen »

I saw a post about this topic 10 years ago
viewtopic.php?t=38427

Is the same situation still present?
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: I cannot set GuidList type parameter on runtime

Post by Lech Kulikowski »

Hello,

Please try to check the following code:

Code: Select all

report.Dictionary.Variables.Add(new StiVariable("", "Variable1", "Variable1", "", typeof(StringList), "", false, StiVariableInitBy.Value, true, new StiDialogInfo(StiDateTimeType.Date, "", true, new string[] {
                    "1",
                    "2"}, new string[] {
                    "1",
                    "2"}), null, false, StiSelectionMode.FromVariable));
Thank you.
ruen
Posts: 3
Joined: Fri Mar 15, 2024 12:25 pm

Re: I cannot set GuidList type parameter on runtime

Post by ruen »

Hello, Thank you Lech.
It works!

You don't have to add new variable, if you want to change existing variable on the fly, just re-assign StiDialogInfo.
You should set your parameters as string[] even your variable type is GuidList.

Make sure Variable's readonly parameter is false.

Code: Select all

stiVariable.DialogInfo = new StiDialogInfo(StiDateTimeType.Date, "", true, new string[] {
                    "1",
                    "2"}, new string[] {
                    "1",
                    "2"})
Lech Kulikowski
Posts: 6271
Joined: Tue Mar 20, 2018 5:34 am

Re: I cannot set GuidList type parameter on runtime

Post by Lech Kulikowski »

Hello,

You are welcome.
Post Reply