Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Label word wrapping [duplicate]

Is there a way to do a word wrap in a .NET label control?

I know there is an alternate way of using a TextBox, make property BorderStyle to none, property ReadOnly to true and set property WordWrap and property Multiline to true.

Is there something for a label?

like image 420
Sharpeye500 Avatar asked Mar 01 '12 00:03

Sharpeye500


People also ask

How do I wrap text in a Windows label?

Select the label you're dynamically adding text to. Look at the properties for the label and turn off AutoSize. You will now be able to drag/set the area for the label and it will automatically auto-wrap to stay within those parameters.

How do I wrap text around a label in HTML?

HTML <pre> tag defines preformatted text. It is used to display code blocks since it preserves spaces and line breaks. If the line is large, then the <pre> tag won't wrap it by default. To wrap it, we need to use CSS.

How do you wrap label content in WPF?

In WPF, the Label control does not support text wrapping. If you need a label that wraps contents across multiple lines, you can use a TextBlock control. Place a TextBlock control inside a Label and apply wrapping on TextBlock.

How do you wrap text in UILabel?

If you set numberOfLines to 0 (and the label to word wrap), the label will automatically wrap and use as many of lines as needed. If you're editing a UILabel in IB, you can enter multiple lines of text by pressing option + return to get a line break - return alone will finish editing.


1 Answers

Change your maximum size,

label1.MaximumSize = new Size(100, 0); 

And set your autosize to true.

label1.AutoSize = true; 

That's it!

like image 150
fa wildchild Avatar answered Sep 16 '22 11:09

fa wildchild