How to make line break in CrystalReports?

Hello
I'm developing application in VB.NET
I have crated crystalReport with TextObject "Header".
Now I need to change text in "Header" based on what I get from database.
I also need to break the text in specified places.
So if I have in my database:     "This is my Header \n New line is here"
I need to break line on "\n"
I tried Replace("string", "\n",NewLine) but its not working.
How can I break line in crystalreport?

Best Regards
FooKy
LVL 11
f_o_o_k_yAsked:
Who is Participating?
 
mlmccConnect With a Mentor Commented:
When you say replace do you mean you will change the field on the fly or are you replacing it with a formula.

The CHR(10) or chr(13) should work to replace the \n.
Have you tried using the built in HATML display capability?

If you right click the field and click FORMAT FIELD
One of the options on the PARAGRAPH tab is TEXT INTERPRETATION.  Select HTML

mlmcc
0
 
Jorge PaulinoIT Pro/DeveloperCommented:
Have you tried to use all this:

Chr(10)
Chr(13)
or
VbCrLf

0
 
f_o_o_k_yAuthor Commented:
Hello,
Sorry for delay but there was a power cut-off in my neighbourhood due to strong winds.

Below I attach code with description of what I'm trying to do.

I also looked at format field -> paragraph tab but there was nothing about text interpretation (maybe because its not full version of CrystalReports but only this what is VS 2005 TeamSuite)
See screenshot.

Best Regards
FooKy
Dim rtxt As CrystalDecisions.CrystalReports.Engine.TextObject = CType(rpt1.ReportDefinition.ReportObjects.Item("TextHeader"), CrystalDecisions.CrystalReports.Engine.TextObject)
 
rtxt.Text = Replace(dr2("header"), "\n", vbNewLine)
'Also tryed 
rtxt.Text = Replace(dr2("header"), "\n", Chr(10) & Chr(13))
rtxt.Text = Replace(dr2("header"), "\n", "<br>")
rtxt.Text = Replace(dr2("header"), "\n", "<br />")
rtxt.Text = Replace(dr2("header"), "\n", vbCrLf)

Open in new window

paragraph.png
0
 
Jorge PaulinoConnect With a Mentor IT Pro/DeveloperCommented:
When I want to use text with breaks I always use parameter fields. Add a new parameter field and then do this:

Dim strFooter As String = "My text using breaks ..."
Dim rpt As New rptTest()
rpt.SetParameterValue("txtFooter", strFooter) 'txtFooter is the name of the parameter field in the report

jpaulino
0
 
f_o_o_k_yAuthor Commented:
Thanks.
Both answers were accurate.
First i thought that mlmcc was taking about text object but TEXT INTERPRETATION is only in parameter field.
so I used it and code from jpaulino and replaced \n to

Best Regards
FooKy
0
All Courses

From novice to tech pro — start learning today.