Unable to Display User Variable and Project Parameter Set from Code

Hello,

I’m trying to pass values from my C# code to a report in List & Label 30, but I cannot get them to display in the report.

Specifically:

  • The report contains a User Variable called prova and a Project Parameter called idCollo.

  • I’m setting these values from code, but in the report print preview it do not show any value.

  • In the report, I have Text Objects with the formulas @prova and @idCollo intended to display the respective values.

Questions:

  1. What is the correct way to assign values to a User Variable or Project Parameter from C# in List & Label 30?

  2. Is there anything specific I need to do when using AutoProjectFile and AutoProjectType?

  3. Are there any important differences between User Variables and Project Parameters in this context?

Note: I do not have the Premium/Enterprise version of List & Label, so I am unable to use the API methods that might normally facilitate passing variables or parameters.

Any guidance would be greatly appreciated.

Thank you in advance!

Code:
using var ll = new ListLabel();

ll.AutoShowSelectFile = false;
ll.ProjectParameters[“idCollo”].Value = “1111”;
ll.Variables.Add(“idCollo”, “1111”);
ll.DataSource = Articoli.ToList();
ll.Variables[“prova”] = “1111”;

ll.AutoDestination = LlPrintMode.Preview;

ll.AutoProjectFile = reportPath;

ll.AutoProjectType = LlProject.List;
ll.ProjectParameters[“idCollo”].Value = “1111”;

ll.Variables.Add(“idCollo”, “1111”);
ll.Variables[“prova”] = “1111”;

ll.Print();
}

Here, it is important to consider the fundamental differences between variables, user variables, and project parameters.

  • Providing data in List & Label is done with dataproviders. Within List & Label, variables and fields are the dynamic text blocks for reports and contain the dynamic part of the data. Variables usually change once per page or report—an example is the header data of an invoice with invoice number and addressee. Fields, on the other hand, usually change for every record; a typical example would be the item data of an invoice. If only a small amount of additional information is to be passed, it is possible to add variables directly.

  • User Variables are a way of saving values and expressions for later use in your layout. Data for user variables can come from the data source or the additional registered variables or fields. User Variables are used as an advanced function within the Designer. You can define and edit user variables in the “Edit User Variables” dialog. However, if you want to set user variables from your code, the correct way is to use our DOM-API, which is, like you said, for Professional/Enterprise Edition only.

  • Project parameters, on the other hand, allow you to set project-specific parameters. List & Label itself uses predefined project parameters, for example, for mail settings.

  • The value for AutoProjectType Property depends on which type of project you want to create. The individual project types - List, Card, Label - serve different purposes. The setting specified via the AutoProjectFile Property must correspond to the selected project type.

Hope this helps.

Thank you for the detailed explanation regarding variables, user variables, and project parameters. I understand now the differences and the limitations regarding setting user variables from code without the DOM-API.

Could you please clarify how I can create simple variables directly from the Desktop Designer so that I can use them in my report and assign values from code?

It seems I understood that only by calling

ll.Variables.Add("Prova", "111");
ll.Design();

and then saving the report, I am able to see the simple variable inside the Designer and assign it to a text object afterwards.

Is this the correct approach?

Yes, adding the data prior to the design or print call using LL.Variables.Add() is a correct approach if the data is constant during the runtime of the report. If only a few variables need to be registered in addition to the data source, this can be done easily in this way.