Page 1 of 1

Check to see if variable exists in dictionary

Posted: Fri Aug 27, 2010 5:20 pm
by bclay
I wanted to know if there was a way I could check to see if a variable has been added to the report dictionary.

For example, in my code I have this expression:

StiReport report = new StiReport();

if (Add == true)
{
report.Dictionary.Variables.Add(new StiVariable("Custom", "Title", "Report"));
}

In the Report Designer, is there a function or expression that I can use to determine if the variable "Title" exists in the report dictionary?


Check to see if variable exists in dictionary

Posted: Sat Aug 28, 2010 3:06 am
by Alex K.
Hello,

You can use the following code:

Code: Select all

foreach (Stimulsoft.Report.Dictionary.StiVariable var in report.Dictionary.Variables)
{
      if (var.Name == "VariableAddName")
      {
            Add = false;
      }
}
Thank you.

Re: Check to see if variable exists in dictionary

Posted: Mon Sep 27, 2021 10:34 am
by Jose
StiReport report = new StiReport();

if (report.Dictionary.Variables.Contains("variablename") == true)

Re: Check to see if variable exists in dictionary

Posted: Mon Sep 27, 2021 2:04 pm
by Lech Kulikowski
Hello,

Thank you.