CustomFunctions Class
Enables you to register custom functions in the End-User Report Designer‘s Expression Editor.
Namespace: DevExpress.XtraReports.Expressions
Assembly: DevExpress.XtraReports.v19.2.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
Remarks
The CustomFunctions class allows you to register custom functions in the Expression Editor to use for specifying control expression bindings and calculated fields expressions along with built-in functions
You can declare a custom function by implementing an ICustomFunctionOperator interface that provides the base functionality. Implement an ICustomFunctionOperatorBrowsable interface if you want to specify additional function information such as a category, description or parameter count.
After creating a custom function, register it in the End-User Report Designer by calling the static CustomFunctions.Register method with the corresponding class instance passed as a parameter.
To unregister a specific function, use the static CustomFunctions.Unregister method.
The following example demonstrates how to create a simple custom function and register it in the End-User Designer.
using DevExpress.XtraReports.UI;
using DevExpress.XtraReports.Expressions;
// ...
public class MyCustomFunction : ICustomFunctionOperator {
object ICustomFunctionOperator.Evaluate(params object[] operands) {
// Insert your custom logic here.
// For demonstration purposes, multiply an operand value to 10.
return (Convert.ToDouble(operands[0]) * 10);
}
string ICustomFunctionOperator.Name {
get { return "MyFunction"; }
}
Type ICustomFunctionOperator.ResultType(params Type[] operands) {
return typeof(double);
}
}
public Form1() {
// ...
CustomFunctions.Register(new MyCustomFunction());
reportDesigner1.OpenReport(new XtraReport());
}