Home > Archive > C# > August 2004 > line break in a windows application
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
line break in a windows application
|
|
| Nurchi BECHED 2004-08-13, 8:57 pm |
| 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", ((char)13) and ((char)10) - they don't work.
When I enter a break by hand (just press enter) and run through
each character in that string, the line break character has code
13 10 (yes, 2 numbers for some reason)
The possible reason is that 'Enter' is a "control" key (a char with
ASCII code less than 32) - they usually return 2 numbers...
What should I do to break line in the textbox?
Alternative way was to use TextWriter:
string LineBreak=(new System.IO.StringWriter()).NewLine;
but there must be another way of doing it...
and then just use that string:
this.TextBox1.AppendText("Hello"+LineBreak+"World");
That is kind of stupid...
With best regards, Nurchi BECHED.
| |
| tbarstow 2004-08-19, 2:38 pm |
| quote: Originally posted by Nurchi BECHED
Hello, All!
When I enter a break by hand (just press enter) and run through
each character in that string, the line break character has code
13 10 (yes, 2 numbers for some reason)
The possible reason is that 'Enter' is a "control" key (a char with
ASCII code less than 32) - they usually return 2 numbers...
Windows line breaks *are* two characters. A linebreak on windows is \n\r -- a linebreak followed by a carriage return (13 10 in decimal). So, what you see is normal.
This should help you with generating linebreaks for windows users, but be careful. Each of the major platforms handles linebreaks differently:
WINDOWS: \n\r
UNIX: \n
MACINTOSH: \r
I leave it up to you to figure out how to decide which type of linebreak to generate.
Cheers,
taylor | |
| Jan van den Broek 2004-08-23, 8:57 pm |
| Thu, 19 Aug 2004 14:38:12 -0500
tbarstow <tbarstow.1bbz5u@mail.codecomments.com> schrieb:
[Schnipp]
>Windows line breaks *are* two characters. A linebreak on windows is
>\n\r -- a linebreak followed by a carriage return (13 10 in decimal).
Small nitpick, carriage return ('\r') followed by a linefeed ('\n').
--
Jan v/d Broek
balglaas@xs4all.nl
"Geef je over, wy zyn Bassie en Adriaan, weerstand is nutteloos"
| |
| Samuel Hon 2004-08-24, 9:07 am |
| System.Enviroment.NewLine
|
|
|
|
|