Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to insert a carriage return into a textbox 2

Status
Not open for further replies.

vatawna

Programmer
Feb 24, 2004
67
US
Hi,

I use "\n" to add a carriage return to a string, and then assign that whole thing to the text property of the textbox control as follows:

txtMessage.Text = "\n" + someString;

The problem is the textbox shows a square and the string.

Does anyone know how to insert a carriage return to the text property of a textbox control.

Thanks.
 
Hello

I don't think we can insert a carriage return into the textbox. You could create a textarea and give it the same dimensions as the textbox so it looks the same. Then the carriage return will show.

Regards
Satish
 
Has the textbox had the MultiLine property set true?

And also, you should be using Environment.NewLine rather than embedded a \n into a string.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Newb here, ignore me if I'm miles off but newlines are \r\n for the purposes of text boxes? also as chiph says, MultiLine property should be set to True.
I couldnt see a way of making them autosize, and had to set a positive value for height, to make this work tho.

//karv, newly enjoying C# as a change from PHP.

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top