473,394 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

\n\r in text box

Ant
Hi, I'm using \n\r to attempt to carriage return a string which will be
displayed in a text box, however, the line remains one line. How do I cariage
return a string being displayed in a text box?

e.g.
displayText = "Hello world line one\n\rHello world line two";
textbox.text = displayText;

Thanks very much in advance
Ant
Jan 18 '06 #1
5 14667
Ant <An*@discussions.microsoft.com> wrote:
Hi, I'm using \n\r to attempt to carriage return a string which will be
displayed in a text box, however, the line remains one line. How do I cariage
return a string being displayed in a text box?

e.g.
displayText = "Hello world line one\n\rHello world line two";
textbox.text = displayText;


Use CR LF rather than LF CR:

displayText = "Hello world line one\r\nHello world line two";

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 18 '06 #2
Ant wrote:
Hi, I'm using \n\r to attempt to carriage return a string which will be
displayed in a text box, however, the line remains one line. How do I cariage
return a string being displayed in a text box?

e.g.
displayText = "Hello world line one\n\rHello world line two";
textbox.text = displayText;

Thanks very much in advance
Ant


textbox.multiline = true;
displayText = "Hello world line one\r\nHello world line two";

your carriage return is in the wrong order

\n\r = wrong
\r\n = right
Jan 18 '06 #3
Ant
So simple!

Thank you again
Ant

"Jon Skeet [C# MVP]" wrote:
Ant <An*@discussions.microsoft.com> wrote:
Hi, I'm using \n\r to attempt to carriage return a string which will be
displayed in a text box, however, the line remains one line. How do I cariage
return a string being displayed in a text box?

e.g.
displayText = "Hello world line one\n\rHello world line two";
textbox.text = displayText;


Use CR LF rather than LF CR:

displayText = "Hello world line one\r\nHello world line two";

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Jan 18 '06 #4
You could also use Environment.NewLine instead of \r\n. This is "safer" in
the longrun since Unix/Linux uses \n and Macintosh uses \r, your code will
run correctly on that type of box in the event of your application running
under something like Mono.

"Ant" wrote:
So simple!

Thank you again
Ant

"Jon Skeet [C# MVP]" wrote:
Ant <An*@discussions.microsoft.com> wrote:
Hi, I'm using \n\r to attempt to carriage return a string which will be
displayed in a text box, however, the line remains one line. How do I cariage
return a string being displayed in a text box?

e.g.
displayText = "Hello world line one\n\rHello world line two";
textbox.text = displayText;


Use CR LF rather than LF CR:

displayText = "Hello world line one\r\nHello world line two";

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Jan 18 '06 #5
Neyah <Ne***@discussions.microsoft.com> wrote:
You could also use Environment.NewLine instead of \r\n. This is "safer" in
the longrun since Unix/Linux uses \n and Macintosh uses \r, your code will
run correctly on that type of box in the event of your application running
under something like Mono.


Well, that really depends on what Mono chooses to do with TextBoxes.
There'll be a lot of code which uses Environment.NewLine, and a lot of
code which uses \r\n. Whatever they choose to do, they'll break a lot
of code.

Environment.NewLine is just the default new line string for text files
on that system IMO (and it's not very clearly documented, so it really
is just my opinion) - it needn't dictate what a UI chooses to use.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Jan 18 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Xerxes | last post by:
Hi, I need help in setting up a page where the text wraps around an image. Right now, I am using table, with text in one <td> and the image in the adjacent <td>. The problem is when the text is...
2
by: Macsicarr | last post by:
Hi All Wonder if you could help me. I have created a CMS system that allows the user to enter text and pic 'tags' for their own About us page, eg text.... text.... text.... text.......
40
by: aku | last post by:
I'm looking for the absolute fastest way to count the nr of bits that are set to "1" in a string. Presumably I then first need the fastest way to do this in a byte. I think this is it, but...
2
by: Guoqi zheng | last post by:
Dear sir, I am using the default paging function of datagrid. Below is my code. <PagerStyle NextPageText="&gt;&gt;&gt;" PrevPageText="&lt;&lt;&lt;" HorizontalAlign="Center" Mode="NumericPages"></PagerStyle> ...
3
by: Greg Noss | last post by:
I'm trying to install MySQL. During the security settings portion fo the setup. I keep getting a Connection Error. Error Nr. 1045 Access denied for user'root'@'localhost'(using password:YES) ...
3
by: | last post by:
Hallo. I would like to make a Query, which gives the order nr to fields of the table. The table has Fields: Date and Notes. And the Query should give the number seriatim by each date. By new date...
17
by: =?Utf-8?B?TWljaGVsIFBvc3NldGggW01DUF0=?= | last post by:
Hello , Does someone knows a simple way of how to get the nr of fraction digits ? example : 1.23 would give a result of 2 1.234 would give a result of 3 Yes
9
by: scripteaze | last post by:
Im using mechanize method for retrieving the form so that i may log into it. I need to find a way to get the form name. Its not listed anywhere in the html source.The reason i need to do this is...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.