473,395 Members | 2,006 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

C# TextBox and Hard Line Breaks

I need my textbox to work more smoothly with respect to line breaks.
When I have data pulled from the database into a textbox there are hard
line breaks at the end of each line (by definition how Lines property
works, right?). But, the textbox is used for editing data previously
entered into the database. Ideally, what I want is just a hard break
at the end of each paragraph so users can smoothly enter or remove data
anywhere without pushing hard line breaks around into the middle of
subsequent lines or have lines broken in the middle.

Any suggestions on how to accomplish this would be greatly appreciated.

Mike

Nov 17 '05 #1
2 13176
I'm a bit confused by your question -- Every time you mention TextBox,
you mention your database in the same sentence, so it's not clear where the
hard-line breaks are coming from.

You to not need to use the Lines property to retrieve the text. You
could use the Text property, which should not have the line breaks in it.
Mike wrote:
I need my textbox to work more smoothly with respect to line breaks.
When I have data pulled from the database into a textbox there are
hard line breaks at the end of each line (by definition how Lines
property works, right?). But, the textbox is used for editing data
previously entered into the database. Ideally, what I want is just a
hard break at the end of each paragraph so users can smoothly enter
or remove data anywhere without pushing hard line breaks around into
the middle of subsequent lines or have lines broken in the middle.

Any suggestions on how to accomplish this would be greatly
appreciated.

Mike


--
Truth,
James Curran [erstwhile-MVP]
Home: www.noveltheory.com Work: www.njtheater.com
Blog: www.honestillusion.com Day Job: www.partsearch.com
Nov 17 '05 #2
Hi James,

I don't think the requirements for this project are that demanding, but
I have not been able to make it work well yet. I am using the text box
to present text that has previously been stored in the database as a
set of lines (with text type, text line sequence and text description
-- which is the actual text I need to present to be edited). The lines
can be no longer than 74 characters long in the database so I am using
courier new so that wordwrap occurs in the textbox at 75 characters.
Because the text actually has some formatting already done to it (like
below) I must maintain that for readability. I want to use the Lines
property to do a foreach loop and save the text back to the database
while attaching a line sequence and text type. Based on the
documentation for the text box I can get an array of strings (each a
line), but which has a hard line break where word wrap occurs. (like
right below)

Example one as text begins in the text box -- \r\n at end of each row
1)
Dr. Smith closed the incision at 11:43 followed by Dr. Johnson \r\n
who had not gotten any sleep in at least three days and was\r\n
dangerous when let loose......\r\n
Anesthesia Time: 2:33\r\n

The problem is if someone edits and puts in new text like in example 2.

2) Text has been added to the second line which pushes the \r\n down
into the next row
and makes the formatting messy. Surgeons hate this.

Dr. Smith closed the incision at 11:43 followed by Dr. Johnson \r\n
who had not gotten any sleep in at least three days and was
exceedingly\r\n
dangerous when let loose......\r\n
Anesthesia Time: 2:33\r\n

http://msdn.microsoft.com/library/de...linestopic.asp

I am sending a message EM_FMTLINES which does a nice job giving me line
breaks where the word wrap occurs and so I get a nice array to loop
through and save to the DB, but it still leaves the \r\n in the middle
of lines as above after 'exceedingly'. Same thing occurs when text is
deleted (i.e text below does not scoot up naturally as there may be
hard line breaks in the middle of one or more lines now).

Sorry about the length, but trying to got a good explanation.

Thanks,
Mike

Nov 17 '05 #3

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

Similar topics

3
by: HDB | last post by:
Ok. I have a windows form with a textbox for displaying certain messages. Multiline=true and wordwrap=true. I want to know the amount of the lines currently showing. That should not be any...
1
by: Developer | last post by:
VC++ 2005 Express Edition: I have a textBox with the properties: this->m_TextBox_Desc->Multiline = true; this->m_TextBox_Desc->WordWrap = true; this->m_TextBox_Desc->ScrollBars =...
1
by: Tedmond | last post by:
Dear all, I have deployed my windows application to several user PCs with XP and Win2000. However, there is something strange that ONE of the TextBox Validated event doesn’t fire in ONE of...
2
by: dancer | last post by:
Using ASP.Net and VB.net I have textboxes (<asp:textbox id......>) in which the user will be entering paragraphs. They are multiline (several rows and several columns). The carriage returns...
4
by: =?Utf-8?B?UmVuYXVkIExhbmdpcw==?= | last post by:
Hello, I have a strange yet very simple problem with the asp.net Textbox web control. On an empty asp.net page, add a single asp:TextBox control with Autopostback=false with nothing else on...
10
by: Neil | last post by:
Using the MS Rich Textbox Control 6.0 in Access 2000, I need to concatenate several RTB controls into a single RTF file. Sometimes two strings will be side-by-side; other times they need to be...
2
by: Nathan Sokalski | last post by:
I have a multiline TextBox that I want to display the text used to create a control in an apsx file. I want each of these to be on a separate line in the TextBox. The only way I know of to place...
1
by: Jim in Arizona | last post by:
On one page I have a datalist where a message is bound to a label. On another page I have the datalist which allows for the insert of new message as well as being able to edit those messages. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.