This is a migrated thread and some comments may be shown as answers.

Line break issue in multi line text boxes

3 Answers 383 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris Ward
Top achievements
Rank 1
Chris Ward asked on 27 Jan 2011, 03:30 PM
Hello,

I have a multiline text box that I am filling with data from my SQL Server.  The contents of this field contain paragraphs of text with line breaks.  When I preview the report or run the project and view in the "Report Viewer" the line breaks are not shown.  If I look at the HtmlPreview I do see the line breaks as expected.  If I display the contents of the text box to the debugger using System.Diagnostics.Debug.Print I can see the linebreaks fine in the output window. If I export the report to PDF, I also see the line breaks. 

So it seems that the data is good but I have problems when viewing the the report viewer or preview mode.  Any suggestions on what may be going on here?

Thanks,

Chris

3 Answers, 1 is accepted

Sort by
0
Michael Salzlechner
Top achievements
Rank 1
answered on 27 Jan 2011, 05:01 PM
I am having a similar issue. Hard linebreaks do not work in the preview. Soft line breaks do work in the preview but do not in the report itself. When i add a subreport above the multi line text it suddenly shows soft and hard line breaks properly but doesnt push other textboxes down any longer and overlaps all the text
0
Peter
Telerik team
answered on 28 Jan 2011, 06:37 PM
Hi guys,

@ Chris: Did you use a Carriage Return (\r) as new line character. If this is the case, then because Telerik Reporting and Silverlight are only able to handle line feed (\n) and \r\n as a new line character my suggesting is to use a replace method to manage the unexpected behavior. For example with the following User Function:

public static object ReplaceCarriageReturn(string value)
{
    return value.Replace("\r", "\r\n");
}

@Michael: we will need a sample project, so we suggest to continue the discussion in the support thread you've opened.

Greetings,
Peter
the Telerik team
Get started with Telerik Reporting with numerous videos and detailed documentation.
0
Ryan
Top achievements
Rank 1
answered on 05 Jul 2011, 01:21 AM
the official support was on the right track but did not work for me. Im using vb, but I needed to do an additional find / replace to make it work from the database, my userfunction is as follows:

Public Shared Function MultilineHack(data As String) As String
  
data = data.Replace("\r", "\r\n")
  
data = data.Replace(vbCr, vbCrLf)
  
Return data
  
End Function

Another hot tip, if you haven't discovered user functions, have a look at the link in the telerik admin post, they are way easy, and you can access them through the expression editor once you have built the project.

HTH
Tags
General Discussions
Asked by
Chris Ward
Top achievements
Rank 1
Answers by
Michael Salzlechner
Top achievements
Rank 1
Peter
Telerik team
Ryan
Top achievements
Rank 1
Share this question
or