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

Label on multiple lines

9 Answers 6720 Views
Label
This is a migrated thread and some comments may be shown as answers.
Bob
Top achievements
Rank 1
Bob asked on 16 May 2008, 09:09 PM
How do I make a label span multiple lines?

I'd like to avoid using multiple labels.

9 Answers, 1 is accepted

Sort by
0
Accepted
Martin Vasilev
Telerik team
answered on 17 May 2008, 04:27 PM
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
0
Bob
Top achievements
Rank 1
answered on 19 May 2008, 07:06 PM
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.
0
Angel
Telerik team
answered on 20 May 2008, 12:09 PM
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
0
Bob
Top achievements
Rank 1
answered on 20 May 2008, 08:39 PM
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. 

0
Accepted
Angel
Telerik team
answered on 21 May 2008, 07:43 AM
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
0
Bob
Top achievements
Rank 1
answered on 21 May 2008, 12:27 PM
That worked, but I'm curious as to why \n wouldn't work in vb.

Thanks!
0
Angel
Telerik team
answered on 22 May 2008, 12:18 PM
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
0
herb
Top achievements
Rank 1
answered on 13 Sep 2017, 02:55 PM

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

And for that matter your "textbox" control?

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 15 Sep 2017, 08:56 AM
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.
Tags
Label
Asked by
Bob
Top achievements
Rank 1
Answers by
Martin Vasilev
Telerik team
Bob
Top achievements
Rank 1
Angel
Telerik team
herb
Top achievements
Rank 1
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or