Mapping plain text to rich text? 
Author Message
 Mapping plain text to rich text?

I've got a RichTextBox (RichTextBox1) and two strings,
where the two strings contain:

String1 = RichTextBox1.Text
String2 = RichTextBox1.Rtf

What I need to do is find where a certain word from
String1 is in the formatted String2.

IE. I need to find where a certain position in String1 is
moved to after the formatting codes are added. Doing it in
the opposite direction would be helpful too.

Any ideas?



Fri, 24 Dec 2004 21:06:11 GMT  
 Mapping plain text to rich text?
What are you wanting to do with this information? Could you use the ability
to define a selection and get the text or RTF for that selection. For
example, select from the beginning of the textbox to the point you are
interested in, then get the RTF for that, the size of that RTF will give you
the offset in the RTF for the whole textbox.

There is also a find function that will select the found text. From that you
can again get the RTF version of the text.

Sam & Matt
VB Team

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> I've got a RichTextBox (RichTextBox1) and two strings,
> where the two strings contain:

> String1 = RichTextBox1.Text
> String2 = RichTextBox1.Rtf

> What I need to do is find where a certain word from
> String1 is in the formatted String2.

> IE. I need to find where a certain position in String1 is
> moved to after the formatting codes are added. Doing it in
> the opposite direction would be helpful too.

> Any ideas?



Mon, 27 Dec 2004 03:47:36 GMT  
 Mapping plain text to rich text?
Unfortunately, there's no built-in feature of the RichText control that maps
a character position between the RTF stream and text.  I did a quick search
of MSDN looking for any functions that would allow you to correlate the
position of a character between the RTF stream and displayed text for that
stream; I wasn't able to find anything.  In order to write such an algorithm
would be rather involved.  You would need to step through each character in
the text string and find the associated character in the RTF stream.  Your
algorithm would need to know about all of the RTF codes in order to factor
them out of the search.

Mike Bond
Visual Basic Development

--
This posting is provided "AS IS" with no warranties, and confers no rights.


Quote:
> I've got a RichTextBox (RichTextBox1) and two strings,
> where the two strings contain:

> String1 = RichTextBox1.Text
> String2 = RichTextBox1.Rtf

> What I need to do is find where a certain word from
> String1 is in the formatted String2.

> IE. I need to find where a certain position in String1 is
> moved to after the formatting codes are added. Doing it in
> the opposite direction would be helpful too.

> Any ideas?



Tue, 28 Dec 2004 04:23:08 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Creating e-mail is always Rich Text NOT Plain Text

2. saving rich text box as plain text

3. Saving Rich Text Box Control as PLAIN TEXT!!!!

4. Rich Text Box: Can I remove text and keep multicolored text

5. Converting formatted text to plain text

6. Formatted text from rich text box to Word

7. Wrapping text around a bmp image in the rich text editor

8. Put text inside a circle in a Rich Text Box

9. Colour Text Box/Class Wrapper for Rich Text Box

10. Some [hopefully] easy questions - text and rich text boxes

11. Rich Text Box: Coloring portions of the text

12. Reading text from another program's Rich Text Box

 

 
Powered by phpBB® Forum Software