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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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,
 
charliewest said:
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".
 
Hi Charlie,

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

HTH,
Rakesh Rajan
 
Rakesh Rajan said:
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.
 
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
 
Rakesh Rajan said:
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.
 
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
 
Back
Top