Evaluates a VBScript expression in the current report context.
Namespace:
C1.C1ReportAssembly: C1.C1Report.2 (in C1.C1Report.2.dll)
Syntax
C# |
---|
public Object Evaluate( string expression ) |
Visual Basic |
---|
Public Function Evaluate ( _ expression As String _ ) As Object |
Parameters
- expression
- Type: System..::..String
A string with a VBScript expression to be evaluated.
Return Value
The value of the expression.Remarks
Use this method to evaluate expressions as they would be evaluated while generating a report. This can be useful in designer-type applications, to provide an "Immediate Window" where users can test expressions.
If the expression string contains invalid syntax or causes an evaluation error, the control raises the ReportError event. In this case, the Handled parameter of the event is set to true, so the exception is ignored by default.
Examples
Expressions may contain simple VBScript expressions such as:
Copy CodeC#
Console.WriteLine(_c1r.Evaluate("2+2")); <i>4</i> Console.WriteLine(_c1r.Evaluate(" \"A\" & \"B\" "); <i>AB</i> |
Expressions may also contain references to the Report object and all its sub-objects. For example:
Copy CodeC#
Console.WriteLine(_c1r.Evaluate("Report.DataSource.RecordSource")); <i>SELECT * FROM Employees</i> Console.WriteLine(_c1r.Evaluate("Report.DataSource.Recordset.Fields.Count")); <i>7</i> Console.WriteLine(_c1r.Evaluate("Report.Fields(0).Name")); <i>FirstNameField</i> |
Finally, data fields, Field, and Section objects may be referenced directly by name.
Copy CodeC#
Console.WriteLine(_c1r.Evaluate("FirstNameField.Value")); <i>Andrew</i> Console.WriteLine(_c1r.Evaluate("CategoryName")); <i>Beverages</i> |