Page 1 of 1

Help with before Print C# code

Posted: Wed Jul 03, 2024 3:53 am
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;
}

Re: Help with before Print C# code

Posted: Wed Jul 03, 2024 9:28 pm
by Lech Kulikowski
Hello,

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

Thank you.