473,387 Members | 1,785 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.

Adding new line character to string using TextBox contol (CF)

Hi. I've a rather newbie question:

I'm concatenating several strings, adding "\n" where necessary, and setting
the final string to the text property of a multi-line textBox control.
However, instead of generating new lines, wierd symbols appear in the
textBox. I'm developing using .NET CF for PPC.

What am i neglecting to do to properly format my string?

Thanks,
Nov 16 '05 #1
6 15707
charliewest <ch*********@discussions.microsoft.com> wrote:
Hi. I've a rather newbie question:

I'm concatenating several strings, adding "\n" where necessary, and setting
the final string to the text property of a multi-line textBox control.
However, instead of generating new lines, wierd symbols appear in the
textBox. I'm developing using .NET CF for PPC.

What am i neglecting to do to properly format my string?


Use "\r\n" instead of "\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 #2
Hi Charlie,

Use the Environment.NewLine property. Its a constant for "\r\n" which
depends on the current platform.

HTH,
Rakesh Rajan

"charliewest" <ch*********@discussions.microsoft.com> wrote in message
news:A5**********************************@microsof t.com...
Hi. I've a rather newbie question:

I'm concatenating several strings, adding "\n" where necessary, and setting the final string to the text property of a multi-line textBox control.
However, instead of generating new lines, wierd symbols appear in the
textBox. I'm developing using .NET CF for PPC.

What am i neglecting to do to properly format my string?

Thanks,

Nov 16 '05 #3
Rakesh Rajan <ra**********************@hotmail.com> wrote:
Use the Environment.NewLine property. Its a constant for "\r\n" which
depends on the current platform.


It depends on the current platform, but there's no guarantee that the
default new line for the platform will be the one used for text boxes.
Consider Windows Forms via Mono - should that use \r\n or \n? For
compatibility with other Windows programs, it should use \r\n (and if
you're using WINE, that's what I'd imagine it would use) whereas the
new line for the Linux platform as a whole is \n.

Personally I'd use Environment.NewLine for writing to text files, but
that's all.

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

Just wondering: shouldn't the default new line for the platform be the one
used for controls as well?

Are you trying to say that in different platforms this is not the case?

Regards,
Rakesh Rajan

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Rakesh Rajan <ra**********************@hotmail.com> wrote:
Use the Environment.NewLine property. Its a constant for "\r\n" which
depends on the current platform.


It depends on the current platform, but there's no guarantee that the
default new line for the platform will be the one used for text boxes.
Consider Windows Forms via Mono - should that use \r\n or \n? For
compatibility with other Windows programs, it should use \r\n (and if
you're using WINE, that's what I'd imagine it would use) whereas the
new line for the Linux platform as a whole is \n.

Personally I'd use Environment.NewLine for writing to text files, but
that's all.

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

Nov 16 '05 #5
Rakesh Rajan <ra**********************@hotmail.com> wrote:
Just wondering: shouldn't the default new line for the platform be the one
used for controls as well?
It might be, but I don't think there's any guarantee - especially if
the UI toolkit you're using is one which is really designed for a
different platform (eg using Windows Forms under Mono, possibly via
WINE).
Are you trying to say that in different platforms this is not the case?


I'm saying it *might* not be the place. It's unfortunate that TextBox
doesn't have its own NewLine property, IMO.

--
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
Hi Jon,

Hmm...I think that some kind of a standard should be in place for people
developing UI toolkits. Wonder if MS has published anything of that sort.

Regards,
Rakesh Rajan

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Rakesh Rajan <ra**********************@hotmail.com> wrote:
Just wondering: shouldn't the default new line for the platform be the one used for controls as well?


It might be, but I don't think there's any guarantee - especially if
the UI toolkit you're using is one which is really designed for a
different platform (eg using Windows Forms under Mono, possibly via
WINE).
Are you trying to say that in different platforms this is not the case?


I'm saying it *might* not be the place. It's unfortunate that TextBox
doesn't have its own NewLine property, IMO.

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

Nov 16 '05 #7

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

Similar topics

4
by: Steve Smith | last post by:
I need to add an additional String parameter to a Java SP (DB2 8.1 0 using DB2 Development Center - FP4). Everytime I do this I get the following error message when building:-...
6
by: Nurchi BECHED | last post by:
Hello, All! I have created an application with a multiline textbox on the form. When I press a button, it has to show something and then break the line and show something else. I tried "\n",...
6
by: Maziar Aflatoun | last post by:
Hi, I have a little application that reads a text file line-by-line and processes each line depending on the CVS values. Now I want to change my program to capture this from a textbox. How do...
3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
4
by: david | last post by:
I have trouble to write paragragh with newlines in a multiline textbox control in ASP.NET form. I would like to display an instruction in textbox in the web form. But I do not know how to type...
22
by: DraguVaso | last post by:
Hi, For my application I need the following behavior: When I press F4 the cursor has to move to the next line in my multiline textbox which begins with "0". Finding lines starting with 0 isn't...
10
by: Christopher Lusardi | last post by:
How would I put an end of line character in the second line below? Textbox1.Text = "Hello " Textbox1.Text = Textbox1.Text = "World" Thanks, Chris Lusardi
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...
1
by: Kageoni2 | last post by:
I'm trying to add new records to my database using 4 textboxes, one for each field in my databases table. I've got ID, Firstname, Surname and Course. But I can't figure out at all how to link...
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:
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...
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
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.