[]
        
(Showing Draft Content)

C1.WPF.FlexReport.C1FlexReport.Evaluate

Evaluate Method

Evaluate(string)

Evaluates a VBScript expression in the current report context.

Declaration
public object Evaluate(string expression)
Parameters
Type Name Description
string expression

A string with a VBScript expression to be evaluated.

Returns
Type Description
object

The value of the expression.

Remarks
<p>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:

Console.WriteLine(_c1r.Evaluate("2+2"));
  4
Console.WriteLine(_c1r.Evaluate(" \"A\" & \"B\" ");
  AB

Expressions may also contain references to the Report object and all its sub-objects. For example:

Console.WriteLine(_c1r.Evaluate("Report.DataSource.RecordSource"));
  SELECT * FROM Employees
Console.WriteLine(_c1r.Evaluate("Report.DataSource.Recordset.Fields.Count"));
  7
Console.WriteLine(_c1r.Evaluate("Report.Fields(0).Name"));
  FirstNameField

Finally, data fields, Field, and Section objects may be referenced directly by name.

Console.WriteLine(_c1r.Evaluate("FirstNameField.Value"));
  Andrew
Console.WriteLine(_c1r.Evaluate("CategoryName"));
  Beverages

Evaluate(string, IReportScriptContext)

Evaluates a VBScript expression.

Declaration
public object Evaluate(string expression, IReportScriptContext context)
Parameters
Type Name Description
string expression

A string with a VBScript expression to be evaluated.

IReportScriptContext context

IReportScriptContext interface used to obtain objects available in expression.

Returns
Type Description
object

The value of the expression.