How to add variable category from code
How to add variable category from code
Hello,
I create a number of variables from code and it works well.
I would also like to add categorys to put my variables in but I don't know how to do that from code.
I suspect that i missing something obvious here but i can't figure what it is.
Regards Joakim
I create a number of variables from code and it works well.
I would also like to add categorys to put my variables in but I don't know how to do that from code.
I suspect that i missing something obvious here but i can't figure what it is.
Regards Joakim
How to add variable category from code
Hi Joakim,
Please create a category first:
And we have added the option of registering of the new category for variable automatically into our to-do list.
Thank you.
Please create a category first:
Code: Select all
report.Dictionary.Variables.Add("MyCategory");
report.Dictionary.Variables.Add(new Stimulsoft.Report.Dictionary.StiVariable("MyCategory","MyVariable", "MyAlias",typeof(int),"10",false));
Thank you.
How to add variable category from code
Thank you,
I can't belive I missed that.
On follow up question.
How can I check if a category already exists?
With a 'normal' variable I can just create a new variable and if it exists it will be replaced, but if i do the same with a category i will have two categorys with the same name.
I have tried...
This still adds two categorys.
Regards Joakim
I can't belive I missed that.
On follow up question.
How can I check if a category already exists?
With a 'normal' variable I can just create a new variable and if it exists it will be replaced, but if i do the same with a category i will have two categorys with the same name.
I have tried...
Code: Select all
Report.Dictionary.Variables.Add("myCategory")
If Not Report.Dictionary.Variables.Contains("myCategory") Then
Report.Dictionary.Variables.Add("myCategory")
End If
Regards Joakim
How to add variable category from code
Hi Joakim,
In that case you need add the following code:
Thank you.
In that case you need add the following code:
Code: Select all
Dim addTheCategory As Boolean = True
Dim variable As StiVariable
For Each variable In report.Dictionary.Variables
If (variable.Category = "MyCategory") Then
addTheCategory = False
Exit For
End If
Next
If addTheCategory Then
report.Dictionary.Variables.Add("MyCategory")
End If
How to add variable category from code
Thank's Edward
How to add variable category from code
Hi Joakim,
Please let us know if you need any help.
Thank you.
Please let us know if you need any help.
Thank you.