newlines in textbox

  • Thread starter Thread starter tshad
  • Start date Start date
T

tshad

I am using a TextBox as my status display and "\n" doesn't work.

What would I use to go to the next line in a TextBox.

I am doing something like:

Status.Text += String.Format("Opening
{0}\n",Path.GetFileName(strFile));

But the next line just continues on the same line.

Thanks,

Tom
 
tshad said:
I am using a TextBox as my status display and "\n" doesn't work.

What would I use to go to the next line in a TextBox.

I am doing something like:

Status.Text += String.Format("Opening
{0}\n",Path.GetFileName(strFile));

But the next line just continues on the same line.

Status.Multiline=True?

-Teemu
 
Teemu said:
Status.Multiline=True?

That was already set.

My problem wasn't going to multiple lines. But when I did something like:

Status.Text = "line 1\n"
Status.Text = "line 2\n"

I would get:

line 1line 2.

Turns out I can use the Environment.Newline to get it to work. But I am
surprised that that the "\n" wouldn't work.

Thanks,

Tom
 
tshad said:
I am using a TextBox as my status display and "\n" doesn't work.

What would I use to go to the next line in a TextBox.

I am doing something like:

Status.Text += String.Format("Opening
{0}\n",Path.GetFileName(strFile));

Make sure the textbox' 'Multiline' property is set to 'true'. In addition I
suggest to use "\r\n" as line separator (which is the common line separator
on Windows), or 'Environment.NewLine' if you are targeting different
operating systems using different line separator character sequences.
 
I am using a TextBox as my status display and "\n" doesn't work.

What would I use to go to the next line in a TextBox.

I am doing something like:

Status.Text += String.Format("Opening
{0}\n",Path.GetFileName(strFile));

But the next line just continues on the same line.

Thanks,

Tom

I believe you can use \r\n for cr/lf. You can also use
Environment.Newline:

Status.Text += String.Format("Opening {0}{1}", _
Path.GetFileName(strFile), _
Environment.NewLine)
 
Back
Top