How to Use Variable Functions in EventCode

Stimulsoft Reports.NET discussion
Post Reply
Markus Weiß

How to Use Variable Functions in EventCode

Post by Markus Weiß »

Hi,

i tried to use a dictionary variable function in the Report.BeginRender event to dynamically create a display string for my report. With normal variable all is working as expected, but with function variables i'getting the expression code an not the value. How do i get the correct value an not the expression?

For example the i attached my code. The variables were:

PersonResponsible

Code: Select all

Test
ManagedDisplay

Code: Select all

IIF(Managed="1","Managed",IIF(Managed="0","Unmanaged","All"))
Parameters2Show

Code: Select all

PersonResponsible;ManagedDisplay
ParameterNames2Show

Code: Select all

Resource Owner;Management State
The Result for ParametersDisplayLine is something like:

Code: Select all

Resource Owner=Test, Management State=IIF(Managed="1","Managed",IIF(Managed="0","Unmanaged","All"))
The Code in the Report.BeginRender event is:

Code: Select all

Dim strParameters() as String = Parameters2Show.Split(";"c)
Dim strParameterNames() as String = ParameterNames2Show.Split(";"c)
Dim i as Integer

ParametersDisplay = ""
ParametersDisplayLine = ""

For i = 0 To strParameters.GetUpperBound(0)
	If Me.Dictionary.Variables(strParameters(i)).Value.Length > 0 Then
		If ParametersDisplay.Length > 0 Then
			ParametersDisplay = ParametersDisplay & vbCrLf & strParameterNames(i) & vbTab & "= " & Me.Dictionary.Variables(strParameters(i)).Value
			ParametersDisplayLine = ParametersDisplayLine & ", " & strParameterNames(i) & "=" & Me.Dictionary.Variables(strParameters(i)).Value
		Else
			ParametersDisplay = strParameterNames(i) & vbTab & "= " & Me.Dictionary.Variables(strParameters(i)).Value
			ParametersDisplayLine = strParameterNames(i) & "=" & Me.Dictionary.Variables(strParameters(i)).Value
		End If
	End If
Next
Markus Weiß

How to Use Variable Functions in EventCode

Post by Markus Weiß »

Any suggestions ? Somebody?

Thanks
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

How to Use Variable Functions in EventCode

Post by Edward »

Please use the following code:

Code: Select all

Me.Item("MyVariableWithExpression").ToString
In the Dictionary of the report template the expression representation is stored, but in runtime variable can be evaluated as the code above. Expression may be calculated with using of the variables with default values without "Functions" when they have usual default values.
But here is one nuance. Variables order is important in the Dictionary. In the order of their representation they will be created. So please pay attention to it.

Thank you.
Post Reply