Expression Editor

  • 3 minutes to read

This document describes different versions of the Expression editor available in various DevExpress products and provides an overview of the syntax that is used to create expressions.

This document consists of the following sections.

Syntax Overview

The Expression editor supports a variety of math, date-time, string and logical functions. To learn more about the supported functions, refer to Criteria Language Syntax.

The following syntax conventions should be taken into account when using the Expression editor.

  • A data field is referenced by enclosing its name in square brackets (e.g., [Products.ProductName]).
  • Query parameters are referenced by typing a question mark before their names (e.g., ?parameter1).

    Report parameters are referenced by adding the "Parameters." prefix before their names (e.g., [Parameters.parameter1]).

  • String values are denoted with apostrophes. An attempt to use quotes instead will result in an error.

    To embed an apostrophe into an expression's text, type a double apostrophe (e.g., 'It''s sample text').

  • Date-time constants should be enclosed with hashtags (e.g., [OrderDate] >= #1/1/2016#).

    expression-editor-date-time-constants

  • To represent a null reference (one that does not refer to any object), use a question mark (e.g., [Region] != ?).
  • If an expression involves the use of different types, you can convert them to the same type using dedicated functions (e.g., Max(ToDecimal([Quantity]),[UnitPrice])).

To learn more, see Criteria Language Syntax.

New Expression Editor

Some of the DevExpress products are shipped with a newer version of the Expression editor that is illustrated in the following image.

expression-editor-intellisense-overview

These products are listed below:

This editor supports syntax highlighting and intelligent code completion (suggesting functions as you type). When selecting a function, a tooltip is invoked, displaying the function's description.

expression-editor-intellisense-invoke-functions

Typing a left square bracket will invoke a popup window listing all available data columns. When selecting a column, a tooltip is invoked, displaying the column's data type.

expression-editor-intellisense-invoke-fields

If an expression contains any errors, the editor immediately highlights them in-place, without invoking dialog windows.

expression-editor-parser-error

Customization API

A public API for customizing the Expression Editor is available in the DevExpress.Data.Controls.ExpressionEditor and DevExpress.DataAccess.ExpressionEditor namespaces.

For a code sample, see the following example online: How to customize the Expression Editor.

TIP

You can use the ExpressionEditorUIHelper class's methods to invoke the Expression Editor in your application at runtime.

Legacy Expression Editor

The following image illustrates the older Expression editor version shipped with certain DevExpress products.

ExpressionEditor

Unlike the newer version this editor does not support intelligent code completion, syntax highlighting and immediate indication of errors.

Selecting the Editor Version

To switch back your Windows Forms application to the use of the legacy Expression Editor, set the WindowsFormsSettings.DefaultSettingsCompatibilityMode property to v16 at the application startup.

To learn more, see Version Compatibility: Default Property Values.

See Also