473,699 Members | 2,539 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Displaying MultiLine Content in a TextBox

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?

Sep 6 '07 #1
4 2075
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.New Line this will assure you to use
the correct new line format.
Sep 6 '07 #2
On Sep 6, 10:09 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions .comwrote:
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.New Line 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.

Sep 6 '07 #3
Hi,

<za***@construc tion-imaging.comwrot e in message
news:11******** **************@ 57g2000hsv.goog legroups.com...
On Sep 6, 10:09 am, "Ignacio Machin \( .NET/ C# MVP \)" <machin TA
laceupsolutions .comwrote:
>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.New Line 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.

so do as I suggested you, replace \r for Environment.New Line
Sep 6 '07 #4
On Sep 6, 9:04 am, za...@construct ion-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
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?
Be sure that the TextBox's MultiLine property is set to true.

Chris

Sep 6 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
4031
by: Joel Finkel | last post by:
Folks, I have a form that has several TextBoxes, some of which have the TextMode set to MultiLine. Each is pre-loaded with data from a database. The user is allowed to modify each entry. The problem is that only the modified data from the SingleLine TextBoxes are returned. The original data are returned for the MultiLine TextBoxes. Also, if the page is sent to the server (for validation, for instance), only the modified data for the...
1
3387
by: Olav Tollefsen | last post by:
I have a MultiLine TextBox to which I add text like this: TextBox1.Attributes.Add("style","overflow :hidden"); TextBox1.Text = "Line 1\r\nLine 2\r\nLine 3"; The number of lines added to the TextBox can be variable. Right now (without setting any width / height), I can only see two lines of text. If I click with the mouse in the TextBox, I can see the rest of the text by moving the the mouse inside the TextBox.
0
1677
by: the friendly display name | last post by:
Hi, I have a filled multiline textbox on the site. I can scroll it with IE and Firefox, but under Opera (tested under 7.54, and Opera 8, under "identify as MSIE" and under Opera identification) , I'm getting a strange behavior: When I try to scroll, the text doesn't move. It only moves to a new position, if I move the scroll marks, and then click on a empty place of the website. There is nothing on the site, just the textbox.
6
2539
by: CalSun | last post by:
Hi all, I try to save a multiline textbox into an sql field (nvarchar(1024)). As I read it out and display, the text drops all the linefeed char. Is there a way to cure this? Thank you all for help. --Calsun
1
1226
by: Yoshitha | last post by:
Hi I have datalist control in my ASP.NET application the problem here is i have used a textbox with multiline true propertly when i enter data like "fdjsfhjksdhfjsdfhsdjhfsdfhsdjfhsd jfdsjfksdjfksdjkfjsdfjksdjfsdjfd fdsfhjsdhfjsdhfjf dsjf dsjfhjsdfhjksdh d fdsjf hsdjkfhdjsfhsdjfh ds
3
22793
by: Rvo | last post by:
I have a userform which contains a textbox (System.Windows.forms.textbox) with multiline set to True. This box contains a certain number of characters which reach below the bottom of the box. During runtime of my program I add text at the end of the contents of the textbox. I want to display the last lines of the box at all times. However, the textbox always displays the first x characters. Can I scroll down to the end of the content of...
10
3662
by: danthman | last post by:
I have a TextBox set up as follows: <asp:TextBox ID="SubjectTextBox" TextMode="MultiLine" MaxLength="100" Columns="50" Rows="2" Wrap="true" runat="server" />
6
8045
Coldfire
by: Coldfire | last post by:
I am having problems with Maxlength of Multiline "Textbox". I have browsed alot to find the solution. Tons of javascripts have been found but they all deal with <asp:textarea >............. and not <asp:TextBox >............. and some of javascripts are 1-------------------------------------------- <script language="JavaScript">
7
15468
by: Anil Gupte | last post by:
I have read a lot about getting lines from a multiline textbox in VB.Net. However, I cannot for the life of me figure out how to write to a multiline textbox. Basically, I have created an array of strings which I want to "paste" into a multiline textbox. Any ideas? -- Anil Gupte www.keeninc.net www.icinema.com
0
8615
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9174
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9034
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5874
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.