Label on multiple lines

10 posts, 2 answers
  1. Bob
    Bob avatar
    72 posts
    Member since:
    May 2008

    Posted 16 May 2008 Link to this post

    How do I make a label span multiple lines?

    I'd like to avoid using multiple labels.
  2. Answer
    Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 17 May 2008 Link to this post

    Hello Bob,

    Thank you for writing.

    There are two ways you can do this:
    1. Using the designer: Navigate to the Text property, open its dropdown button and put the text on different lines using the Enter key.
    2. Programmatically: When you set the Text property by code, use the escape sequence "\n" for a new line:
      this.radLabel1.Text = "First line \n Second line"
    If you need additional assistance, do not hesitate to contact me again.

    Kind regards,
    Martin Vasilev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Bob
    Bob avatar
    72 posts
    Member since:
    May 2008

    Posted 19 May 2008 Link to this post

    Thanks, that's the behavior I'm looking for.

    Considering usability, it would be much easier if the label supported a dragable border.  That way we could resize it while it has text, and it would resize on-the-fly...make it a lot easier than having to find the text property over and over.
  4. Angel
    Admin
    Angel avatar
    121 posts

    Posted 20 May 2008 Link to this post

    Hi Bob,

    Thank you for writing.

    Just like the Microsoft Label, RadLabel cannot be sized by default. In order to apply an arbitrary size to RadLabel, set the AutoSize property to false. By default, in this mode the text is wrapped on multiple lines if the width is not enough to fit the entire text.

    If you have any additional questions, please contact me.

    Best wishes,
    Angel
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Bob
    Bob avatar
    72 posts
    Member since:
    May 2008

    Posted 20 May 2008 Link to this post

    I'm following your suggestion when setting the text programatically, but am not seeing the multiple lines.

    In designer mode I set the text to be:  "First Test" on the first line, and "Second Line" on the second line so that I can know it's changed.  Then when I press a button I set this:

    RadLabel_Instructions.Text = "AAA BB \n CC DD"

    And the result on screen is exactly that - all on one line. 

  6. Answer
    Angel
    Admin
    Angel avatar
    121 posts

    Posted 21 May 2008 Link to this post

    Hi Bob,

    The given sample was for C#. If you are using Visual Basic, the code should be:

    RadLabel_Instructions.Text = "AAA BB " & Constants.vbLf & " CC DD"

    Best wishes,
    Angel
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. Bob
    Bob avatar
    72 posts
    Member since:
    May 2008

    Posted 21 May 2008 Link to this post

    That worked, but I'm curious as to why \n wouldn't work in vb.

    Thanks!
  8. Angel
    Admin
    Angel avatar
    121 posts

    Posted 22 May 2008 Link to this post

    Hello Bob,

    Putting escape characters between the quotation marks is defined by the language. The usage of '\' is specified for C# and combinations like '\n' and '\r' are also language-specific.

    Visual Basic does not allow special characters to be put inside a string.

    For differences between C# and VB, you may refer to the comparison articles below:

    http://www.harding.edu/fmccown/vbnet_csharp_comparison.html#Strings

    or

    http://www.codeproject.com/KB/dotnet/vbnet_c__difference.aspx

    I hope this helps. If you have any further questions, please contact me.

    Sincerely yours,
    Angel
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. herb
    herb avatar
    1 posts
    Member since:
    Sep 2017

    Posted 5 days and 22 hours ago Link to this post

    Is there no multiple line or wrap around for the "telerik:Label"?

    And for that matter your "textbox" control?

  10. Dess
    Admin
    Dess avatar
    2043 posts

    Posted 4 days and 4 hours ago Link to this post

    Hello Herb, 

    Thank you for writing.  

    By default, RadLabel is auto-sized. That is why it is not wrapped. It is necessary to set the AutoSize property to false and specify the size. Here is a sample code snippet: 
    this.radLabel1.Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rutrum libero eget aliquam hendrerit. ";
    this.radLabel1.AutoSize = false;
    this.radLabel1.Size= new Size(100,100);

    As to the RadTextBox, it is necessary to enable multiline text: 
    this.radTextBox1.Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce rutrum libero eget aliquam hendrerit. ";
    this.radTextBox1.Size = new Size(100, 100);
    this.radTextBox1.AutoSize = false;
    this.radTextBox1.Multiline = true;

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top