New to Telerik UI for WinForms? Start a free 30-day trial

Customizing RadExpressionEditor

Updated on Aug 27, 2026

Creating custom expression functions

Although Telerik provides a large number of predefined functions, some scenarios require additional functionality. You can create a custom expression method for use in RadExpressionEditor or as a value of the Expression property. To do that, create a class that inherits from the ExpressionContext class:

C#
public class CustomExpressionContext : Telerik.Data.Expressions.ExpressionContext
    {
/// <summary>
/// My custom function, which returns Pi constant.
/// </summary>
/// <returns></returns>
public double Pi()
{
    return Math.PI;
}
    }   

Once implemented, assign the new custom ExpressionContext class by using the static Context property:

C#
Telerik.Data.Expressions.ExpressionContext.Context = new CustomExpressionContext();

Then you can use the new expression method:

C#
this.radGridView1.Columns["expression"].Expression = "PI()";

Customizing the functions list

RadExpressionEditor supports loading functions, operators and constants from an XML file. This allows for customizing the available elements, localizing functions descriptions and adding custom functions. All available values should be described in the source XML file according to the following XML structure:

xml
	<?xml version="1.0" encoding="utf-8" ?>
	<ExpressionItemsList>
	  <!-- Custom functions -->
	  <ExpressionItem Name="GetPi (Custom Function)" Value="PI()" Syntax="PI()" Type="OtherFunc">
	    <Description>
	      Get the value of Pi. This is a custom added function.
	    </Description>
	  </ExpressionItem>
	
	  <ExpressionItem Name="Sum" Value="SUM()" Syntax="SUM([List(Of Number)])" Type="AggregateFunc">
	    <Description>
	      Computes the sum of a sequence of values.
	    </Description>
	  </ExpressionItem>
	</ExpressionItemsList>

To load a prepared XML source file, use the LoadFromXML method as shown below:

C#
string path = "Telerik.Examples.WinControls.GridView.Expressions.ExpressionItemsListData.xml";
Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(path);
RadExpressionEditorForm.ExpressionItemsList.LoadFromXML(stream);

ExpressionEditorFormCreated event

This event fires before the expression editor form is shown. The following example changes the BackColor and hides the icon in the title bar:

C#
private void RadGridView1_ExpressionEditorFormCreated(object sender, ExpressionEditorFormCreatedEventArgs e)
{
    e.ExpressionEditorForm.FormElement.TitleBar.FillPrimitive.BackColor = Color.LightSkyBlue;
    e.ExpressionEditorForm.ShowIcon = false;
}

See Also