
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?