carpbyte
asked on
Rich Text Box does not find text spanning lines
I can' t believe this can't be done -
I have a rich text box with multiple lines of text. If I attempt to search for a phrase that SPANS lines, the text is NOT found.
Ex.
Here's a line of
multiple text
rtf.Find("of multiple", iLastHit, RichTextBoxFinds.None) will return NO hit (I assume because between "of" and "multiple" is an OD OA.)
Even if you modify the string to INCLUDE the 0D0A it STILL doesn't find the text.
I can't believe that a rich text box doesn't allow a search across multiple lines...
Any ideas?
Thanks.
I have a rich text box with multiple lines of text. If I attempt to search for a phrase that SPANS lines, the text is NOT found.
Ex.
Here's a line of
multiple text
rtf.Find("of multiple", iLastHit, RichTextBoxFinds.None) will return NO hit (I assume because between "of" and "multiple" is an OD OA.)
Even if you modify the string to INCLUDE the 0D0A it STILL doesn't find the text.
I can't believe that a rich text box doesn't allow a search across multiple lines...
Any ideas?
Thanks.
iLastHit = rtf.Find(TextBox1.Text, iLastHit, RichTextBoxFinds.None)
If iLastHit = -1 Then
iLastHit = 0
MsgBox("Text not found", MsgBoxStyle.Information, "Search Transcript")
Else
rtf.SelectionStart = iLastHit
rtf.SelectionLength = txt.Text.Length
rtf.SelectionBackColor = Color.Red
iLastHit = iLastHit + 1
End If
ASKER
This works, but how do I set the search start point AFTER the last find in order to find additional instances of the phrase?
(note - I did find a solution by creating a text string out of ALL of the rtf and then replacing the Chr(10), however this looks like a more elegant soultion if it can search past each found location...)
Thanks.
(note - I did find a solution by creating a text string out of ALL of the rtf and then replacing the Chr(10), however this looks like a more elegant soultion if it can search past each found location...)
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yeah I just thought of that...
Thanks
Thanks
Open in new window