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.
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.
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;
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