By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,953 Members | 1,562 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,953 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.