[]
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 reporting in ExpressionEditor provides immediate feedback for invalid expressions. The control supports:
error display through the ShowErrorBox property
syntax highlighting through the UnderlineErrors property
validation checks through the IsValid property.
These features help identify, display, and correct expression errors during editing.
ExpressionEditor provides visual options for displaying validation errors within the user interface.
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. |
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. |
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
}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 |
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;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.
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 |
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:
IsValid validates the expression before evaluation.
ItemContext assigns the current data item used during evaluation.
TryEvaluate evaluates the expression against the current context.
Successful evaluation returns the evaluated result for display or processing.
Failed evaluation returns validation details through GetErrors().