Finding Text in a RichTextBox

J

Joe Cool

I am working on an application that has a form that has a multiline
RichTextBox control. I am trying to add functionality to find text in
the control and highlight it. I have the user enter the text to be
searched for in a dialog box. The dialog has a Find and a Find Next
button. Of course, the Find Next is not enabled until the user clicks
on the Find button. Since there is a Find Next button, I want the
dialog to remain visible after doing a Find or Find Next AND I want
the found text to be highlighted and visible at the same time.
Highlighting the found text is easy by just selecting it. But after
selecting it, the dialog box regains focus and as soon as it does, the
selected text in the RichTextBox control is no longer visibly
selected, even though it still is. If I close the dialog, the
highlighting of the selected text returns. How do I get the selected
text to remain visibly selected after the dialogbox regains focus?

I know this can be done somehow because I hace seen another commercial
app I have that does the same exact thing.
 
J

Joe Cool

Set the RichTextBox's HideSelection property to false.

Thanks, I'll try that. As you may suspect this related to my other
question you have responded to.
 

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