Extend Designer by Custom Function

The following example shows how a function can be added that allows querying a registry key within a report. The result of the function could be used in appearance conditions for objects for example. Of course, the properties of the DesignerFunction class can also be set directly in the properties window of the development environment.

ListLabel LL = new ListLabel();
LL.DataSource = CreateDataSet();

 

// Initialize function

DesignerFunction RegQuery = new DesignerFunction();

RegQuery.FunctionName = "RegQuery";

RegQuery.GroupName = "Registry";

RegQuery.MinimalParameters = 1;

RegQuery.MaximumParameters = 1;

RegQuery.ResultType = LlParamType.String;

RegQuery.EvaluateFunction += new EvaluateFunctionHandler(RegQuery_EvaluateFunction);

 

// Add function

LL.DesignerFunctions.Add(RegQuery);

 

LL.Design();
LL.Dispose();

 

 

void RegQuery_EvaluateFunction(object sender, EvaluateFunctionEventArgs e)

{

    // Get registry key

    RegistryKey key = Registry.CurrentUser.OpenSubKey(@"Software\combit\");

    e.ResultValue = key.GetValue(e.Parameter1.ToString()).ToString();

}