MultiLine TextBox

Hi,
Can anybody help me how to set the text of a multiline textbox with a string that has line feeds.
When i write the code as below,

TextBox myText ;
myText.multiline = true ;
myText.Text = "option_one \n option_two" ;

I don't get the "option_one" and "option_two" displayed in two seperate lines in the TextBox and instead get it in a single line with a character inbetween. I am expecting your suggestions to achieve the desired result. Thanks.

[525 byte] By [vijay_jan80] at [2007-12-16]
# 1
Hi
try using


myText.AppendText("option_one\n");

myText.AppendText("option_two\n");


Eisa at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
Hi Eisa,
Thanks for the reply. When i tried this, I get a newline character at the end of the text in the textbox. Also the contents with newline character that goes in to the textbox is read from a .txt file. So I need to try out for other options to get the result.
vijay_jan80 at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 3
I think for a multiline textbox it's "\r\n"
Kaetemi at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 4
Hi kaetemi
I've tried the "\r\n" and it didn't work
Eisa at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 5
The "\r\n" is system dependent......replace with the constant VbCrlf
RichardWeir at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 6
Borrowed the use of the Split method from another thread on this forum. Thought it might work for you...

string myText = "option_one \n option_two";
myTextBox.Lines = myText.Split('\n');

dkocur2 at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 7
The easiest and envinronment-independent mechanism is to use Environment.NewLine() to add a new blank line.

This should work,
Dan Fernandez
Product Manager
http://blogs.msdn.com/danielfe/

Dan at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 8

To programatically populate a multiline textbox (myText) with multiple lines, set the "Lines" property of the TextBox instance to a string array (lineArray) as follows:

string[] lineArray = new string[2];
lineArray[0] = "option_one";
lineArray[1] = "option_two";
myText.Lines = lineArray;

Pivinski at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 9
The only working solution to this specific problem
I ever came up with is this:

myText.AppendText("option_one" & vbNewLine)
myText.AppendText("option_two" & vbNewLine)

I know this will work, as I have used it my self.
All the best

PitBull.ja at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms General...