By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,315 Members | 1,672 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,315 IT Pros & Developers. It's quick & easy.

C# TextBox and Hard Line Breaks

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.