Table of Contents

Class DesignerFunction

Namespace
combit.Reporting
Assembly
combit.ListLabel31.CrossPlatform.dll

Represents a user provided designer function that can be used to extend the List & Label Designer with custom functionality. Designer functions allow you to add custom calculations, data lookups, or any other custom logic that can be invoked from within report expressions in the Designer.

public class DesignerFunction
Inheritance
DesignerFunction
Inherited Members

Examples

This example demonstrates how to create a custom function that queries the Windows Registry. The function can be used in report expressions to make decisions based on registry values.

using combit.Reporting;
using Microsoft.Win32;

public class ReportHelper
{
    public void SetupCustomFunction()
    {
        using (ListLabel LL = new ListLabel())
        {
            // Define/Assign data source
            LL.DataSource = CreateDataSet();

            // Initialize function
            DesignerFunction regQuery = new DesignerFunction
            {
                FunctionName = "RegQuery",
                GroupName = "Registry",
                Description = "Queries a Windows Registry key value",
                MinimalParameters = 1,
                MaximumParameters = 1,
                ResultType = LlParamType.String,
                Visible = true
            };

            // Configure the parameter
            regQuery.Parameter1.Description = "Registry key path";
            regQuery.Parameter1.Type = LlParamType.String;

            // Subscribe to the evaluation event
            regQuery.EvaluateFunction += RegQuery_EvaluateFunction;

            // Add function to the ListLabel instance
            LL.DesignerFunctions.Add(regQuery);

            // Do something with the instance here, e.g. print a report
            ...
        }
    }

    private void RegQuery_EvaluateFunction(object sender, EvaluateFunctionEventArgs e)
    {
        try
        {
            // Get registry key
            RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\combit\");
            if (key != null)
            {
                object value = key.GetValue(e.Parameter1?.ToString());
                e.ResultValue = value?.ToString() ?? string.Empty;
            }
            else
            {
                e.ResultValue = string.Empty;
            }
        }
        catch (Exception ex)
        {
            // Handle errors appropriately
            e.ResultValue = $"Error: {ex.Message}";
        }
    }
}

This example shows a more complex function with multiple parameters:

// Create a function that calculates tax based on amount and tax rate
DesignerFunction calcTax = new DesignerFunction
{
    FunctionName = "CalculateTax",
    GroupName = "Business",
    Description = "Calculates tax amount based on net amount and tax rate",
    MinimalParameters = 2,
    MaximumParameters = 2,
    ResultType = LlParamType.Double,
    IsConstantForConstantData = true
};

calcTax.Parameter1.Description = "Net amount";
calcTax.Parameter1.Type = LlParamType.Double;
calcTax.Parameter2.Description = "Tax rate (%)";
calcTax.Parameter2.Type = LlParamType.Double;

calcTax.EvaluateFunction += (sender, e) =>
{
    if (e.Parameter1 != null && e.Parameter2 != null)
    {
        double amount = Convert.ToDouble(e.Parameter1);
        double rate = Convert.ToDouble(e.Parameter2);
        e.ResultValue = amount * (rate / 100);
        e.DecimalPositions = 2;
    }
    else
    {
        e.ResultValue = 0.0;
    }
};

LL.DesignerFunctions.Add(calcTax);

Remarks

Designer functions can accept up to 4 parameters of different types (string, numeric, date, boolean, etc.) and return a result of a specified type. The function logic is implemented by subscribing to the EvaluateFunction event, which is raised whenever the function is called during report rendering.

Common use cases include:

  • Querying external data sources or APIs during report generation
  • Performing custom calculations not available in built-in functions
  • Implementing business-specific logic (e.g., tax calculations, formatting rules)
  • Accessing system resources (e.g., registry, environment variables, file system)

Constructors

DesignerFunction()

Initializes a new instance of the DesignerFunction class.

public DesignerFunction()

Properties

Description

Gets or sets the description of the designer function.

public string Description { get; set; }

Property Value

string

FunctionName

Gets or sets the name of the designer function.

public string FunctionName { get; set; }

Property Value

string

GroupName

Gets or sets the group name of the designer function.

public string GroupName { get; set; }

Property Value

string

IsConstantForConstantData

Gets or sets a value indicating whether the designer function is constant for constant data.

public bool IsConstantForConstantData { get; set; }

Property Value

bool

MaximumParameters

Gets or sets the maximum number of parameters the designer function can have.

public int MaximumParameters { get; set; }

Property Value

int

MinimalParameters

Gets or sets the minimal number of parameters the designer function can have.

public int MinimalParameters { get; set; }

Property Value

int

Parameter1

Gets or sets the first parameter of the designer function.

public DesignerFunctionParameter Parameter1 { get; set; }

Property Value

DesignerFunctionParameter

Parameter2

Gets or sets the second parameter of the designer function.

public DesignerFunctionParameter Parameter2 { get; set; }

Property Value

DesignerFunctionParameter

Parameter3

Gets or sets the third parameter of the designer function.

public DesignerFunctionParameter Parameter3 { get; set; }

Property Value

DesignerFunctionParameter

Parameter4

Gets or sets the fourth parameter of the designer function.

public DesignerFunctionParameter Parameter4 { get; set; }

Property Value

DesignerFunctionParameter

ResultType

Gets or sets the result type of the designer function.

public LlParamType ResultType { get; set; }

Property Value

LlParamType

Visible

Gets or sets a value indicating whether the designer function is visible.

public bool Visible { get; set; }

Property Value

bool

Events

CheckFunctionSyntax

Occurs when the syntax of the designer function is checked.

public event CheckFunctionSyntaxEventHandler? CheckFunctionSyntax

Event Type

CheckFunctionSyntaxEventHandler

EvaluateFunction

Occurs when the designer function is evaluated.

public event EvaluateFunctionEventHandler? EvaluateFunction

Event Type

EvaluateFunctionEventHandler

ParameterAutoComplete

Occurs when the parameter auto-complete is triggered for the designer function.

public event ParameterAutoCompleteEventHandler? ParameterAutoComplete

Event Type

ParameterAutoCompleteEventHandler