This example shows how to add a custom function. First, you need to create a function:
...

 	public static decimal MySum(object value)
	{
		if (!ListExt.IsList(value))
		return Stimulsoft.Base.Helpers.StiValueHelper.TryToDecimal(value);

		return Stimulsoft.Data.Functions.Funcs.SkipNulls(ListExt.ToList(value))
		.TryCastToDecimal()
		.Sum();
	}

...

Next, use AddFunction() to add this function to StiFunctions:
...

	private void AddCustomFunction()
	{
		StiFunctions.AddFunction(
		"My Category", "MySum", "description",
		typeof(MyClass),
		typeof(decimal),
		"Calculates a sum of the specified set of values.",
		new[] { typeof(object) },
		new[] { "values" },
		new[] { "A set of values" }).UseFullPath = false;
	}
	
...

After that, you can use AddCustomFunction() in the main class after component initialization:
...

	public FormMain()
	{

		InitializeComponent();
		AddCustomFunction();
	}
	
...

In the screenshot below you can see the result of the sample code:

Adding a Custom Function to the Designer

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.