Help with before Print C# code

Stimulsoft Reports.NET discussion
Post Reply
Mattob
Posts: 1
Joined: Tue Jul 02, 2024 4:21 am

Help with before Print C# code

Post by Mattob »

I was hoping the following would work to separate a list of records with a ";" and terminate the last record with a "."

DataBand1
Source = "CollectionEvent"
Text component name = "Text1"

I get error messages using the following C# code in Before Print for Text component "Text1". Any help or advice appreciated.

private void DataBand1_BeforePrint(object sender, EventArgs e)
{
// Assuming that "CollectionEvent" is the name of your data source
var records = CollectionEvent.ToList();
var formattedRecords = "";

for (int i = 0; i < records.Count; i++)
{
formattedRecords += records.CalcFullName; // Using the CalcFullName field

if (i < records.Count - 1)
{
formattedRecords += "; ";
}
else
{
formattedRecords += ".";
}
}

// Assign the formatted string to the named text component
TextComponent1.Text = formattedRecords;
}
Lech Kulikowski
Posts: 7333
Joined: Tue Mar 20, 2018 5:34 am

Re: Help with before Print C# code

Post by Lech Kulikowski »

Hello,

Please send us a sample report with test data that reproduces the issue for analysis.

Thank you.
Post Reply