473,769 Members | 8,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 13202
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
1454
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 rocket-science, eh? Textbox.lines.length() only returns the amount of lines ending with a 'hard' CrLF, not the lines with a 'soft' CrLf done by the wordwrapping option. Why, I don't know. I don't want to know how much lines are ending with 'hard' CrLf....
1
1468
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 = ScrollBars::Vertical; I read my database with a description for the user. I want to load each line into a listView. With wordWrap and the Width of the textBox gives
1
1295
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 the PC. Basically, the service pack and the .Net framework are same. I could not find out what cause the problem from that PC. Does anyone has such experience before and tell me why and how to solve it? Thanks for any help!
2
17025
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 that the user puts in (return/enter key) do not show up when the data is retrieved. It is one long line. Is there any way to make the user's paragraph divisions show up in the report?
4
5958
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 the page. according to the doc, hitting Enter while the TextBox has focus should do nothing since Autopostback=false. The problem i have is that it posts the form (that is, it ignores the Autopostback=false).
10
3521
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 separated by a hard return. For example, say I have the following 4 RTB controls in my form: RTB1 = "abcd" RTB2 = "efgh" RTB3 = "ijkl" RTB4 = "mnop"
2
5830
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 things on separate lines in a TextBox without doing it programmatically is the following: <asp:TextBox ID="txtMultiLine" runat="server" TextMode="MultiLine"> Line 1 Line 2 Line 3 </asp:TextBox>
1
2655
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 editing (EditItemTemplate) has a textbox that loads the message into its text property. The problem I'm running into is working with vbCrLf and <brinterchangeably between the textbox on the admin page and the label on the general message page. I...
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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
10219
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...
1
9998
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9865
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
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
6675
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();...
2
3567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.