Skip to main content

Expression Editor Dialog

  • 3 minutes to read

The Expression Editor dialog allows users to specify formulas for calculated fields (columns or rows) in the ExpressQuantumGrid, ExpressQuantumTreeList, and ExpressVerticalGrid controls. The dialog uses the ExpressSpreadSheet formula engine which supports Microsoft Excel-compatible operators, constants, and functions.

This topic includes the following sections:

  • Expression Editor UI

  • Invoke Expression Editor at Design Time

  • Give End-User Access at Runtime

  • How to Use Expression Editor

  • Errors and Confirmation Messages

Note that server mode data controllers do not support calculated fields.

Expression Editor UI

Expression Editor Dialog

The table below lists the editor’s UI elements.

UI Element Description
Expression Box Allows you to type an expression.
Categories Displays the editor’s built-in and custom elements by category. Select a category and choose the element in the “Available Elements” panel.
Available Elements Lists elements contained in the selected category. The Field category displays items whose VisibleForExpressionEditor property value is True even if they are invisible in the control.
Search Box Allows you to locate an element by name.
Element Description Displays an element’s description.

Invoke Expression Editor at Design Time

Select an item and click the DataBinding.Expression property’s ellipsis button in the Object inspector to call the editor.

Give End-User Access at Runtime

The code snippet below shows how to invoke the editor via the ShowExpressionEditor procedure for a specific column (cxGrid1DBTableView1Column1) in a data-aware Table View:

cxGrid1DBTableView1Column1.ShowExpressionEditor;

The Table View and Banded Table View allow users to invoke the Expression Editor via the column header popup menu. If the view’s OptionsCustomize.ColumnExpressionEditing property is set to True, the menu displays the “Expression Editor…” item.

To disable this menu item for a specific column, set this column’s Options.ExpressionEditing property value to False.

How to Use Expression Editor

There are two ways to create valid expressions:

  • Double-click elements listed in the dialog to add them to the expression.

  • Type an element’s name and press Ctrl+Space to enable Formula AutoComplete.

The Expression Editor displays the following message if the text does not match any element:

The editor’s syntax highlighter colors the text based on the applied skin.

Errors and Confirmation Messages

The table below shows Expression Editor error messages:

Error Message

Example

Solution

Syntax Error

PRODUCT([Unit Price] [Quantity

Avoid typos.

PRODUCT([Unit Price],[Quantity])

Separate items with commas when you pass them as a function’s parameters.

PRODUCT([Unit Price]:[Quantity])

Do not use item value ranges in expressions. Parse routines interpret this as a syntax error, because data controller items do not support the same functionality as Spread Sheet cells. Always list all references to items individually (see the previous example).

Unknown Field

Use only registered functions and existing fields.

Unknown Function

Field names should be enclosed in []

[UnitPrice]

Wrap an item’s caption in square brackets.

Strings should be enclosed in single or double quotes

‘It’’s a simple text’

Enclose string values in apostrophes. To use an apostrophe in a string constant, add an additional apostrophe as an escape character.

The following message is displayed if you close the dialog without saving changes:

Click Yes or No to confirm or discard changes and close the dialog. To continue editing, click Cancel.

The following message is displayed when you attempt to save an expression that contains an unregistered function or non-existent field:

If you click Yes, it can result in the #NAME? error.

See Also