In This Topic
If only a few variables or fields are to be added to the data of the data source, there are two possibilities:
- If the data is constant during the runtime of the report, it can just be added prior to the design or print call by using LL.Variables.Add.
- If the data changes from page to page or even from line to line, the information can be passed within the AutoDefineNewPage or AutoDefineNewLine events by using LL.Fields.Add or LL.Variables.Add.
The following example shows both approaches:
void LL_AutoDefineNewLine(object sender, AutoDefineNewLineEventArgs e)
{
// Switch to next record if necessary
// GetCurrentFieldValue is function of your application
// which returns the content of a data field.
(sender as ListLabel).Fields.Add("AdditionalData.AdditionalField", GetCurrentFieldValue());
}
// ...
using (ListLabel LL = new ListLabel())
{
// Define/Assign data source
LL.DataSource = CreateDataSet();
// Define additional data fields
LL.Variables.Add("AdditionalData.UserName", GetCurrentUserName());
LL.Variables.Add("AdditionalData.ProjectName ", GetCurrentProjectName());
// ...
// Add event handling for own fields
LL.AutoDefineNewLine += new AutoDefineNewLineHandler(LL_AutoDefineNewLine);
// Call the Designer
LL.Design();
// Print
LL.Print();
}
Private Sub LL_AutoDefineNewLine(sender As Object, e As AutoDefineElementEventArgs) Handles LL.AutoDefineNewLine
' Switch to next record if necessary
' GetCurrentFieldValue is function of your application
' which returns the content of a data field.
TryCast(sender, ListLabel).Fields.Add("AdditionalData.AdditionalField", GetCurrentFieldValue())
End Sub
// ...
Using LL As New ListLabel()
' Define/Assign data source
LL.DataSource = CreateDataSet()
' Define additional data fields
LL.Variables.Add("AdditionalData.UserName", GetCurrentUserName())
LL.Variables.Add("AdditionalData.ProjectName ", GetCurrentProjectName())
' ...
' Call the Designer
LL.Design()
' Print
LL.Print()
End Using