[]
        
(Showing Draft Content)

Error Reporting

ExpressionEditor validates expressions after input is completed. If an expression contains invalid syntax or unsupported tokens, the control detects the error and displays a validation message within the editor.

This validation behavior helps identify and correct errors before expression evaluation or execution.


Error Display and Validation

Error reporting in ExpressionEditor provides immediate feedback for invalid expressions. The control supports:

These features help identify, display, and correct expression errors during editing.

ExpressionEditor provides visual options for displaying validation errors within the user interface.


ShowErrorBox

The ShowErrorBox property controls whether an error message is displayed within the editor when a syntax error occurs.

Declaration

public bool ShowErrorBox { get; set; }
c1ExpressionEditor1.ShowErrorBox = true;

Property

Description

ShowErrorBox

Displays error messages for invalid expressions.


UnderlineErrors

The UnderlineErrors property controls whether invalid portions of an expression are visually underlined.

Note: Note: The feature requires IntelliSyntaxHighlightingEnabled to be enabled.

Declaration

public bool UnderlineErrors { get; set; }
c1ExpressionEditor1.UnderlineErrors = true;

Property

Description

UnderlineErrors

Controls whether invalid portions of an expression are visually underlined.


Validation

The IsValid property indicates whether an expression passes validation.

  • true → The expression is valid and can be evaluated.

  • false → The expression contains validation errors and cannot be evaluated.

Example

if (c1ExpressionEditor1.IsValid)
{
    // Expression is valid
}

GetErrors Method

The GetErrors() method retrieves the validation errors detected in the current expression. The method returns a collection of ErrorInfo objects that describe syntax or validation issues identified by the editor.

List<ErrorInfo> errors = c1ExpressionEditor1.GetErrors();

Declaration

public List<ErrorInfo> GetErrors()

Return Type

Type

Description

List<ErrorInfo>

A collection of ErrorInfo objects that contain expression error details.


ItemContext Property

The ItemContext property specifies the data object used as the evaluation context for expressions.

ItemContext represents the active data item used during expression evaluation. When the DataSource property is assigned, the control typically configures ItemContext automatically. Manual assignment is required only when custom evaluation behavior is needed.

Declaration

public object ItemContext { get; set; }

Example

c1ExpressionEditor1.ItemContext = currentRow;

Result Preview

ExpressionEditor provides a result preview feature that evaluates and displays the output of an expression before it is applied.

This behavior helps verify expression accuracy and preview evaluation results within the current data context. Evaluation errors are displayed when the expression cannot be processed.

Evaluation Behavior

  • Expressions are evaluated only when validation succeeds.

  • Evaluation uses the current data context.

  • Successful evaluation returns the computed result.

  • Failed evaluation returns false, and error information is available for retrieval.


TryEvaluate Method

The TryEvaluate method evaluates the current expression and returns a Boolean value indicating whether evaluation completed successfully. When evaluation succeeds, the result is returned through the out parameter.

The following example evaluates an expression and assigns the result to a text box when evaluation succeeds:

Declaration

public bool TryEvaluate(out object result)
object result;

if (c1ExpressionEditor1.TryEvaluate(out result))
{
    textBox1.Text = result.ToString();
}

Parameters

Parameter

Type

Description

result

object

The result parameter contains the evaluated expression value when evaluation succeeds.


Example with Data Binding

In data-bound scenarios, expressions are evaluated against the current item in the bound data source.

The following example assigns the current DataRow to ItemContext, evaluates the expression, and displays either the result or validation errors:

var table = _data.DataSource as DataTable;
c1ExpressionEditor1.ItemContext = table.Rows[_data.Position];

object result;
if (c1ExpressionEditor1.TryEvaluate(out result))
{
    textBox1.Text = result.ToString();
}
else
{
    textBox1.Text = c1ExpressionEditor1.GetErrors()[0].ToString();
}

Expression Evaluation Sequence

Expression evaluation follows a validation and execution sequence that includes validation, context assignment, evaluation, and error handling:

  1. IsValid validates the expression before evaluation.

  2. ItemContext assigns the current data item used during evaluation.

  3. TryEvaluate evaluates the expression against the current context.

  4. Successful evaluation returns the evaluated result for display or processing.

  5. Failed evaluation returns validation details through GetErrors().