Quick Start

This quick start topic guides you through a step-by-step process of creating Expression Editor control, and binding it to an object to demonstrate creating expressions and performing operations on its fields.

The steps to create an application with Expression Editor control are as follows:

The following image exhibits Expression Editor control.

Expression Editor Control

Back to Top

Step 1: Add Expression Editor components to application

  1. Create a Windows Forms application, and open Form1.cs.
  2. Add C1ExpressionEditor and C1ExpressionEditorPanel components to your form.

Back to Top

Step 2: Bind the components

Bind the C1ExpressionEditor and C1ExpressionEditorPanel components using ExpressionEditor property exposed by C1ExpressionEditorPanel class, as shown in the following code snippet.

InitializeComponent();
c1ExpressionEditorPanel1.ExpressionEditor = c1ExpressionEditor1;

Back to Top

Step 3: Add Result panel

  1. To create result panel, add a label and a text box control.
  2. Set the text property of label to Result:, and name the text box txtResult.

Back to Top

Step 4: Subscribe to and handle the ExpressionChanged event

Subscribe to the ExpressionChanged event of C1ExpressionEditor, and handle the ExpressionChanged event to show result of the entered expressions, as shown in the following code snippet.

    //...
    c1ExpressionEditor1.ExpressionChanged += c1ExpressionEditor1_ExpressionChanged;
}
private void c1ExpressionEditor1_ExpressionChanged(object sender, EventArgs e)
{
    if (!c1ExpressionEditor1.IsValid)
    {
        txtResult.Text = "";
    }
    else
    {
        txtResult.Text = c1ExpressionEditor1.Evaluate()?.ToString();
    }
}

Back to Top

Step 5: Build and Run the Project

  1. Click Build | Build Solution to build the project.
  2. Press F5 to run the project.

You have successfully created a Windows forms application with Expression Editor control. Enter a valid expression and see the results.

Back to Top