I am attempting to set the contents of a text object in crystal reports to contain the same text (including spacing) as is contained in a C# text box on a form.
I had to avoid parameters to do this because of size constraints.
Unfortunately the spacing is the problem.
The text object on the crystal report does not recognise the new line character. Not \r or \n or \r\n.
My code to transfer the text boxes contents across is as follows. Although I don't think that its the problem.
All help would be VERY much appreciated
c#
body = bodyForm.LetterBody;
//body = body.Replace("\n",Convert.ToChar(13).ToString());
FreeStyleLetter freerpt = new FreeStyleLetter();
freerpt.SetDataSource(freeds);
//Get all the sections in the report
Sections reportSections = freerpt.ReportDefinition.Sections;
foreach(Section section in reportSections) {
//Get all the report objects from each section
ReportObjects reportObjects = section.ReportObjects;
//Loop through each report object
foreach(ReportObject reportObject in reportObjects) {
if (reportObject.Name.Equals("Body") {
try { ((TextObject)reportObject).Text = body;
}
catch(Exception ex) { MessageBox.Show(ex.ToString());
} }
}
}
ReportViewer rv=new ReportViewer(freerpt);
I had to avoid parameters to do this because of size constraints.
Unfortunately the spacing is the problem.
The text object on the crystal report does not recognise the new line character. Not \r or \n or \r\n.
My code to transfer the text boxes contents across is as follows. Although I don't think that its the problem.
All help would be VERY much appreciated
c#
body = bodyForm.LetterBody;
//body = body.Replace("\n",Convert.ToChar(13).ToString());
FreeStyleLetter freerpt = new FreeStyleLetter();
freerpt.SetDataSource(freeds);
//Get all the sections in the report
Sections reportSections = freerpt.ReportDefinition.Sections;
foreach(Section section in reportSections) {
//Get all the report objects from each section
ReportObjects reportObjects = section.ReportObjects;
//Loop through each report object
foreach(ReportObject reportObject in reportObjects) {
if (reportObject.Name.Equals("Body") {
try { ((TextObject)reportObject).Text = body;
}
catch(Exception ex) { MessageBox.Show(ex.ToString());
} }
}
}
ReportViewer rv=new ReportViewer(freerpt);