473,387 Members | 1,492 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,387 software developers and data experts.

easy one // textBox.text and return/new line character....

Hi ,
I have this simple code :

string hopeTextShowsInTwoLines = "lineOne \n line two";
textBox1.Text = hopeTextShowsInTwoLines;

but text shows in one line. What should I do for thenew lines "\n"
characters to send the rest of the text in the new line of the textBox ?

THank You
Nov 16 '05 #1
5 9194
Hi genc ymeri,

First, you should use \r\n and not just \n, as you aren't always
guaranteed that just \n will work.

In your case you need to set the TextBox's MultiLine property to true.

--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #2
"Morten Wennevik" <Mo************@hotmail.com> wrote:
First, you should use \r\n and not just \n


"\r\n" can be used if you only intend your application to run under
Windows.

If you're concerned about portability, use Environment.NewLine.

P.
Nov 16 '05 #3
thnx :)

"Paul E Collins" <fi******************@CL4.org> wrote in message
news:ck**********@titan.btinternet.com...
"Morten Wennevik" <Mo************@hotmail.com> wrote:
First, you should use \r\n and not just \n


"\r\n" can be used if you only intend your application to run under
Windows.

If you're concerned about portability, use Environment.NewLine.

P.

Nov 16 '05 #4
>>First, you should use \r\n and not just \n

Thanks, that made it to work...
"Morten Wennevik" <Mo************@hotmail.com> wrote in message
news:opsfih5yq8klbvpo@pbn_computer...
Hi genc ymeri,

First, you should use \r\n and not just \n, as you aren't always
guaranteed that just \n will work.

In your case you need to set the TextBox's MultiLine property to true.

--
Happy Coding!
Morten Wennevik [C# MVP]

Nov 16 '05 #5
Paul E Collins <fi******************@CL4.org> wrote:
"Morten Wennevik" <Mo************@hotmail.com> wrote:
First, you should use \r\n and not just \n


"\r\n" can be used if you only intend your application to run under
Windows.

If you're concerned about portability, use Environment.NewLine.


I don't know about that - Environment.NewLine is to do with the new
line for the platform in general. There's no guarantee it'll be what
the *text box* uses for a new line. For instance, running with Mono
under Linux, I'd expect Environment.NewLine to be '\n' but if they're
trying to get Windows Forms compatibility with .NET, TextBox may well
still require '\r\n'.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #6

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

Similar topics

0
by: raj | last post by:
I have multiline-text box in my C# application. User enter text into the multiline-text box, and without completing the whole line, user press Enter Key and go to the next line, by leaving the...
10
by: Dave | last post by:
I can't get a number out of my textbox. it keeps giving me an error and saying that the input string was not in the correct format. this.number = int.Parse((this.numberTextBox.Text.ToString()); ...
0
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
0
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
0
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
0
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
0
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
0
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
0
by: Eric | last post by:
Visual C++ 2005 Express MVP's and experience programmer's only please!... I need to get the number of lines in a textbox so I can insert them into a listview. The text comes from my database...
6
by: poojo hackma | last post by:
How is the New Line character written to the TextBox field (TextBox.Multiline=True)? For example: TextBox1.Text = "Line 1\nLine 2"; Above does not produce 2 lines in the TextBox1. Simple...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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.