views:

2971

answers:

2

I have a Winform application build with C# and .Net 2.0. I have a textbox set with MultiLine.

The problem is when someone write text with multiple line (press few enters) and press my save button than close and load the form again. All the new line disappear (the text is there at least).

Example:

Line1

Line3

This will be if I save and load :

Line1 Line3

Any idea why?

Update

The database is PostGres and when I use PGAdmin I can see all the line AND the "enters". So the persistence seem to have save all the line... the problem seem to be when I put back the string in the Textbox.

+1  A: 

If I recall correctly, the textbox is really a string array.

I think you can do this:

textBox1.Lines = foo.Split(new String[] {"\n"},StringSplitOptions.RemoveEmptyEntries);

Edit again: If you want to keep the blank lines, the change to StringSplitOptions.None

Geoff
A: 

In Windows forms all carriage returns are preserved in a multiline text box, so the problem likely lies in the way data is retrieved from your database. I've never used PostGres, but I'm guessing that the way you're retrieving the text from the db is replacing all whitespace with single spaces.

Wyatt