redgar
Member
- Joined
- Feb 28, 2008
- Messages
- 13
- Programming Experience
- 3-5
I have a richtextbox that I'm filling with text from a datagridview. Anywho, as the richtextbox is filling up I want to be able to highlight certain words that match my search word.
My complication at this point is changing the backcolor to all the items in the richtextbox that match the search word. I can change a single word with
txtSelection.SelectionStart = txtSelection.Find(txtSearch.Text)
txtSelection.SelectionBackColor = Color.Yellow
or simply:
txtSelection.Find(txtSearch.Text)
txtSelection.SelectionBackColor = Color.Yellow
The search or selection both stop after finding and highlighting the first word. How would I extend, particularly the Find, to search through the entire richtextbox to select and highlight each matching word?
My complication at this point is changing the backcolor to all the items in the richtextbox that match the search word. I can change a single word with
txtSelection.SelectionStart = txtSelection.Find(txtSearch.Text)
txtSelection.SelectionBackColor = Color.Yellow
or simply:
txtSelection.Find(txtSearch.Text)
txtSelection.SelectionBackColor = Color.Yellow
The search or selection both stop after finding and highlighting the first word. How would I extend, particularly the Find, to search through the entire richtextbox to select and highlight each matching word?