The IF expression may be used as IF(expression, ifTrue, ifFalse):
IF(FirstName = "John", "This is John", "This is not John")
Considering the second issue, you may create a LambdaExpression, which you can compile. Depending on whether the user used any of the fields of the object in the Item property, RadExpressionEditor can also create a LambdaExpression, so you may need to check if the produced expression is not a LambdaExpression first.
var expression = radExpressionEditor1.Expression;
// check if the expression is not a LambdaExpression already
var lambda = expression as LambdaExpression;
if (lambda == null)
// create a LambdaExpression from RadExpressionEditor's expression
lambda = Expression.Lambda(expression);
// compile the LambdaExpression to a Delegate
var del = lambda.Compile();
You can then call the DynamicInvoke method of the Delegate. If the user entered a boolean expression, you can cast the Delegate to Func<Entity, bool>, where Entity is the type of the object in the Item property, which should also match the type of the Entity you would like to test against:
// make sure that lambda.Type == typeof(bool) && lambda.Parameters.Count == 1 && lambda.Parameters.Type = typeof(Entity) before attempting this
var func = del as Func<
var entity = GetSomeEntity();
// do something
Right now the expression returned by RadExpressionEditor does not emit the same string it was parsed from when calling its ToString() method, because we can't control the string representation of the built-in LINQ Expression types in .NET. In order to persist the expression, I recommend to save the value of the ExpressionText property, which is the string that the user entered.
Whenever you need to programatically parse an expression string, you can use the TryParse extension method on RadExpressionEditor, passing the string you saved previously. This method is declared in the Telerik.Windows.Controls namespace, so make sure you have a using for it in your file.
As for the last question, you are not obliged to use the RadExpressionEditor only with RadGridView.
the Telerik team
Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward!
We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>