Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

Displaying MultiLine Content in a TextBox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
zacks@construction-imaging.com - 06 Sep 2007 15:04 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.