asenovm
asenovm

Reputation: 6517

Inserting newline in .NET label

I'd like to insert a newline into a Windows Forms text label through the design view. Something like setting the text to be:

Lorem ipsum \n dolor sit amet

or

Lorem ipsum <br/> dolor sit amet

However, none of the above works. How can one insert a new line into a label? I have a static text that I'll be displaying, so I don't want to do it via code.

Upvotes: 27

Views: 22237

Answers (2)

user287107
user287107

Reputation: 9418

When you edit the "Text" field, you should see a small arrow on the right side of that text box. If you press it, a multiline string editor should appear. Here you can insert your mulitline text.

Upvotes: 38

Water Cooler v2
Water Cooler v2

Reputation: 33850

You can do it in the code as follows:

private void Form1_Load(object sender, EventArgs e)
{
     label1.Text = "This is the first line\r\nAnd this is the second line.";
}

Upvotes: 22

Related Questions