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

Textbox line break

19 Answers 4185 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Boots
Top achievements
Rank 1
Boots asked on 04 May 2009, 09:53 PM
Hello,

I'm having trouble adding a new line to a textbox in a report. I'd like to have a textbox that displays up to 3 different fields on different lines. i"m setting the string "line 1 \r\n line 2 \r\n line 3" i tried a few different combinations. I would like to avoid putting it in the edit expressions if possible. I got it to work for the html side easy enough using <br> but the winform side is the one i'm having troubles with. I'm using Telerik Reporting Q1 2009 release.

Thanks much,
~Boots

19 Answers, 1 is accepted

Sort by
0
Accepted
Steve
Telerik team
answered on 05 May 2009, 08:38 AM
Hi Boots,

In Q1 2009, we've released a new report item - HtmlTextBox. You can use it as a replacement for the standard textbox item and the following would be formatted properly for all formats except excel (yet to come):

line 1 <br />line 2 <br />line 3

Kind regards,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Steve
Telerik team
answered on 05 May 2009, 09:48 AM
Hi Boots,

As a quick follow up I've just tried this with the TextBox item and it works as expected e.g.:

 private void textBox1_ItemDataBound(object sender, EventArgs e) 
        { 
            Telerik.Reporting.Processing.TextBox txt = (Telerik.Reporting.Processing.TextBox)sender; 
            txt.Value = "line 1 \r\n line 2 \r\n line 3"
        } 


Of course this would not work in the Expression editor as it escapes the \r\n characters, but I assumed that you're doing it in code since you've explicitly stated that you do not want this in the expression editor. However it is possible to add this event through the expression editor by pressing enter whenever you want a new line to start and if you check how it is serialized in the InitializeComponent() method, you would notice that the code is the same as the code snippet above.

Greetings,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Boots
Top achievements
Rank 1
answered on 05 May 2009, 02:06 PM
Thanks Steve the HtmlTextBox works great! Just what I was looking for.

Thanks again,
~Boots
0
Brant
Top achievements
Rank 1
answered on 01 Feb 2010, 05:10 PM
I am having the same problem only I am on Q2 2008 which doesn't have the html textbox (which I am looking forward to when we upgrade later this year).  I would rather not write this in code as I have found that to be very buggy in my version of Telerik.  Is there a way to do this in the textbox expression?  Something like:   Fields.Address1 + CRLF + Fields.Address2      ?
0
Steve
Telerik team
answered on 02 Feb 2010, 08:57 AM
Hello Brant,

It would seem that you have not reviewed my last reply to Boots in this thread. Using Enter in the TextBox expression editor would create a new line.

Best wishes,
Steve
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Brant
Top achievements
Rank 1
answered on 02 Feb 2010, 02:14 PM
No I read that and tried it.  when I hit ENTER in the edit expression box it closes the box as if I hit OK. 
0
Steve
Telerik team
answered on 02 Feb 2010, 02:27 PM
Hello Brant,

That is probably because you're using an older version of the product. Try Ctrl + Enter or you can even edit the Value of the TextBox directly in the InitializeComponent() method i.e.:

textBox1.Value = "line 1 \r\n line 2 \r\n line 3";

Regards,
Steve
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Brant
Top achievements
Rank 1
answered on 02 Feb 2010, 02:32 PM
That worked.  I also had to put single quotes around the line break.  Does the trim function work on this?  I basically have address1 + linebreak + address2 + linebreak + city, state, zip.  Sometimes there is no data in address2.  It doesn't seem like trim is working.
0
Steve
Telerik team
answered on 02 Feb 2010, 03:04 PM
Hello Brant,

We would not trim anything out of the box, but you can try using the built-in Trim function.

Best wishes,
Steve
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
devesh
Top achievements
Rank 1
answered on 18 Jun 2011, 07:07 PM
I tried the HtmlTextEditor to display tabular data using table html tag, But the htmlTextEditor doesn't display it on runtime. It will be best if it will support table tag too in future version.

And there must be Grouping option for elements, so that multiple elements on the reports can be moved at a time.
0
Randa
Top achievements
Rank 1
answered on 23 Apr 2012, 07:06 PM
I am using Q2 2011 and I am trying to add a line break before a header group  and will need another line break after the Group footer.
Not sure if that can be done or not.
I tried adding an HTML Text box at the the Group Footer and have its value <br/> but that did not work.
Can you please direct me to what I need to do or provide me with an example.

Thanks
0
Steve
Telerik team
answered on 24 Apr 2012, 09:10 AM
Hi Randa,

It seems you talk about breaks before and after report sections. This functionality is handled by the PageBreak property of report sections.

Kind regards,
Steve
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Randa
Top achievements
Rank 1
answered on 24 Apr 2012, 01:22 PM
Thanks Steve,
I was wondering if I can do a line break not a page break so leave a few lines between each report section.
0
Steve
Telerik team
answered on 24 Apr 2012, 01:29 PM
Hi Randa,

You cannot, all report sections are right after the other. For more info see:

Greetings,
Steve
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Siva
Top achievements
Rank 1
answered on 12 Jul 2012, 12:15 PM
Hi steve,

i am using Telerik_Reporting_Q2_2012, i used HTMl text box for line breaks but, it not working.
i used like this:
line1<br/>line2<br/>line3<br/> .

but it's displayed like this when i run the report. : line1<br/>line2<br/>line3<br/> . 

can u give suggestion for this problem

Thanks in Advance
Siva


0
IvanY
Telerik team
answered on 17 Jul 2012, 07:18 AM
Hello Siva,

Please make sure that you input the HTML code in the Html view and not in the Design view. By default the HtmlTextBox editor starts in the Design view where you enter text and format it using the provided tools; switching to the Html view (the button is situated in the upper left part of the expression builder) you can edit the markup.

Regards,
IvanY
the Telerik team

BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >

0
Steven
Top achievements
Rank 1
answered on 17 Feb 2013, 09:59 PM
I know this is a bit old but you could create a simple Static Helper for this

public static string BR()
{
     return Environment.NewLine;
}


Then you can put this straight in your expression and you can eliminate ItemBinding events or HtmlTextBoxes just for linebreaks.

"=First Line" + BR() + "Second Line" + BR() + "Third Line"


It would be a cool feature if you can define your own Report Constants or Report Level properties that could be read from the Expressions.    Static methods are great, but sometimes you need to evaluate against a handful of values that do not exists on the bound ReportItem.

I always include these in my reports to simplify my expression
public static bool FIND(object rawValue, string values)
{
    string value = Trim2(rawValue);
    return values.Split(',').Contains(value)
}
 
public static string BR()
{
    return Envionment.NewLine;
}
 
public static string Trim2(object rawValue)
{
    return (rawValue + "").Trim();
}
 
public static int Len2(object rawValue)
{
    return (rawValue + "").Trim().Length;
}
 
public static string CleanHtml(string rawHtml)
{
    // Uses HtmlAgilityPack to cleanup messy html to xhtml
    return ReportHelper.CleanHtml(rawHtml);
}
0
Jayaram Krishnan
Top achievements
Rank 1
answered on 17 Dec 2017, 12:10 PM

You can use '<br/>' or replace char(10) by '<br />' in your sql query and then use HtmlDecode function in your report html box expression:

SELECT Comments + '<br/>'

 

{HtmlDecode(Fields.Comments)}

 

This will work perfectly.

 

Madani

0
Rod
Top achievements
Rank 1
answered on 12 Apr 2019, 06:03 PM

In case anyone needs another solution. I wanted two concatenated fields to appear on separate lines in a Telerik Grid then a report but the report could be PDF or exported to Excel. This meant I could not use HtmlTextBox.

So I concatenated the fields using a <br/> which works really well for the grid but then I created a little C# function to replace the <br/> with \r\n as expressions allow for C# functions. Below is the code:

public static string formatBR(object s)
        {
            string temp;

            temp = MNS(s);

            temp = temp.Replace("<br/>", "\r\n");

            return temp;

        }

Here is the expression:

= Online_Reporting.Utilities.formatBR(Trim(Fields.Comments))

This technique has gotten me around many little limitations that I was just too lazy to figure out.

Hope it helps someone.

ROD>

 

Tags
General Discussions
Asked by
Boots
Top achievements
Rank 1
Answers by
Steve
Telerik team
Boots
Top achievements
Rank 1
Brant
Top achievements
Rank 1
devesh
Top achievements
Rank 1
Randa
Top achievements
Rank 1
Siva
Top achievements
Rank 1
IvanY
Telerik team
Steven
Top achievements
Rank 1
Jayaram Krishnan
Top achievements
Rank 1
Rod
Top achievements
Rank 1
Share this question
or