Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add NewLine to label's Text at design time

How can I add newlines to a Label's Text at design time? There are some posts on Stack Overflow on how to do this in code-behind, but there is no post about that for design time yet, it seems?

like image 319
SilverLight Avatar asked Nov 08 '12 18:11

SilverLight


People also ask

How do I add a line break in label text?

When you click on the label Text property in the Property window for the label, a drop down will appear in which you can, when you press Enter , go to the new line. I just tried it, and it works in Visual Studio 2010.

How do you label multiple lines in C#?

We can also use a Panel control to create a multiline label in C#. We can place the desired label inside a panel and then handle the ClientSizeChanged event for the panel. The ClientSizeChanged event is invoked whenever the size of a control inside the panel changes. We can resize the label with the Label.


2 Answers

When you click on the label Text property in the Property window for the label, a drop down will appear in which you can, when you press Enter, go to the new line. I just tried it, and it works in Visual Studio 2010.

Here's a screenshot to clarify:

Editing multiline label

like image 181
Nikola Davidovic Avatar answered Oct 07 '22 20:10

Nikola Davidovic


Design Time \r\n will do the trick -

      label1.Text = "Multi-line \r\nlabel" 

Also you can try setting in designer generated code -

        this.label2.Location = new System.Drawing.Point(151, 120);         this.label2.Name = "label2";         this.label2.Size = new System.Drawing.Size(35, 13);         this.label2.TabIndex = 1;         this.label2.Text = "Multi-line \r\n label"; 

Run time -

      label1.Text = "Multi-line" + Environment.NewLine + "label"; 
like image 28
indiPy Avatar answered Oct 07 '22 20:10

indiPy