I am developing a C#.NET application in VS2005 that needs a function
that allows the user to edit some text content stored in a Text column
in a database. I have a TextBox control with AcceptsReturn, AcceptsTab
and MultiLine properties all set to True.
When I set the Text property of the control to the string returned
from the database and show the form, the content in the textbox isn't
"formatted". All newlines appear as a funky undisplayable character
and does not cause the content following it to appear on the next
line. I dumped the content returned from the database to the Command
window, and it definitely has "\r"'s all through it.
How do I get the text content to appear the same as it would if loaded
into, say, a Notepad window?
Ignacio Machin ( .NET/ C# MVP ) - 06 Sep 2007 15:09 GMT
Hi,
> When I set the Text property of the control to the string returned
> from the database and show the form, the content in the textbox isn't
> "formatted". All newlines appear as a funky undisplayable character
> and does not cause the content following it to appear on the next
> line. I dumped the content returned from the database to the Command
> window, and it definitely has "\r"'s all through it.
In windows you need \r\n at the end. How the text is stored int he DB in the
first place?
Can you post the code you are using to read it from the DB and assign it to
the textbox?
You could replace \r for Environment.NewLine this will assure you to use
the correct new line format.
zacks@construction-imaging.com - 06 Sep 2007 15:20 GMT
On Sep 6, 10:09 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions.com> wrote:
> Hi,
>
[quoted text clipped - 12 lines]
> You could replace \r for Environment.NewLine this will assure you to use
> the correct new line format.
I posted my question before fully investigating this. You are exactly
on the money. The content that was not being displayed correctly had
been imported with only "\r" at the end of each line. I am coming from
VB.NET and am still learning about the differences in the way things
worked.
Ignacio Machin ( .NET/ C# MVP ) - 06 Sep 2007 15:55 GMT
Hi,
> On Sep 6, 10:09 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
> laceupsolutions.com> wrote:
[quoted text clipped - 22 lines]
> VB.NET and am still learning about the differences in the way things
> worked.
so do as I suggested you, replace \r for Environment.NewLine
Chris Dunaway - 06 Sep 2007 16:43 GMT
On Sep 6, 9:04 am, za...@construction-imaging.com wrote:
> I am developing a C#.NET application in VS2005 that needs a function
> that allows the user to edit some text content stored in a Text column
[quoted text clipped - 10 lines]
> How do I get the text content to appear the same as it would if loaded
> into, say, a Notepad window?
Be sure that the TextBox's MultiLine property is set to true.
Chris