RichTextBox Class

T

Thomas Bodell

Hi All,

I have a strange problem i my app. using the RichTextBox Class. I am setting
the text proprty in my control with some text, this text includes "\r\n"
line breakes, and it looks fine. Then I access the control by using some
method e.g. GetLineFormCharIndex() or Select() and then when I look at the
text property all my "\r\n" is just "\n". Has anyone else experienced this
problem? My real problem is that I try to find some text containing "\r\n"
by using IndexOf() on the text property, and the search string comes from a
database and contains "\r\n".

TIA

Thomas Bodell
 
S

Stoitcho Goutsev \(100\)

Thomas,

I have always wondered why Micorosft decided to use 2 symbols in the first
place (back to MSDOS days) for new line since '\n' is the new line character
used by all unix systems. Anyways they even made it wors when decided to fix
thinks cople of years ago and as a result no one knows what to use. RichEdit
v1.0 used \r\n, but since v2.0 it uses '\n'. It still excepts the old \r\n,
but internally it converts it to single '\n' character.

What I can suggest is to fix one of the strings before comparison. You can
use String.Replace either to replace all \n characters in the text read from
the richbox to \r\n or lose the \r from the data that came from the
database.

You can also prepare a regex based on the data from the database and use it
for finding the matches.
 
T

Thomas Bodell

Stoitcho,

Thank's for your infomation, then I know how to attack my problem.

Thomas Bodell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top