Textbox line break

18 posts, 1 answers
  1. Boots
    Boots avatar
    80 posts
    Member since:
    Dec 2008

    Posted 04 May 2009 Link to this post

    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

  2. Answer
    Steve
    Admin
    Steve avatar
    10942 posts
    Member since:
    May 2014

    Posted 05 May 2009 Link to this post

    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.

  3. Steve
    Admin
    Steve avatar
    10942 posts
    Member since:
    May 2014

    Posted 05 May 2009 Link to this post

    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.

  4. Boots
    Boots avatar
    80 posts
    Member since:
    Dec 2008

    Posted 05 May 2009 Link to this post

    ThanksĀ Steve the HtmlTextBox works great! Just what I was looking for.


    Thanks again,
    ~Boots

  5. Brant
    Brant avatar
    18 posts
    Member since:
    Oct 2008

    Posted 01 Feb 2010 Link to this post

    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      ?

  6. Steve
    Admin
    Steve avatar
    10942 posts
    Member since:
    May 2014

    Posted 02 Feb 2010 Link to this post

    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.

  7. Brant
    Brant avatar
    18 posts
    Member since:
    Oct 2008

    Posted 02 Feb 2010 Link to this post

    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. 

  8. Steve
    Admin
    Steve avatar
    10942 posts
    Member since:
    May 2014

    Posted 02 Feb 2010 Link to this post

    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.

  9. Brant
    Brant avatar
    18 posts
    Member since:
    Oct 2008

    Posted 02 Feb 2010 Link to this post

    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.

  10. Steve
    Admin
    Steve avatar
    10942 posts
    Member since:
    May 2014

    Posted 02 Feb 2010 Link to this post

    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.

  11. devesh
    devesh avatar
    2 posts
    Member since:
    Mar 2011

    Posted 18 Jun 2011 Link to this post

    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.

  12. Randa
    Randa avatar
    14 posts
    Member since:
    Jul 2011

    Posted 23 Apr 2012 Link to this post

    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

  13. Steve
    Admin
    Steve avatar
    10942 posts
    Member since:
    May 2014

    Posted 24 Apr 2012 Link to this post

    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 >

  14. Randa
    Randa avatar
    14 posts
    Member since:
    Jul 2011

    Posted 24 Apr 2012 Link to this post

    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.

  15. Steve
    Admin
    Steve avatar
    10942 posts
    Member since:
    May 2014

    Posted 24 Apr 2012 Link to this post

    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 >

  16. Siva
    Siva avatar
    25 posts
    Member since:
    May 2012

    Posted 12 Jul 2012 Link to this post

    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


  17. IvanY
    Admin
    IvanY avatar
    412 posts
    Member since:
    Sep 2012

    Posted 17 Jul 2012 Link to this post

    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 >

  18. Steven
    Steven avatar
    81 posts
    Member since:
    Dec 2011

    Posted 17 Feb 2013 Link to this post

    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);
    }

Back to Top