Put your RichTextBox in place of the richtext, and replace Color.Blue with the Color of your choice.
#WORD RICH TEXT CONTENT CONTROL GRAYED OUT HOW TO#
But, I still haven't shown you how to use it :) Here: private void button1_Click(object sender, EventArgs e)įind(richtext, textBox1.Text, Color.Blue) So, basically, that is the "Finding" or "Searching" method. While ((index = (word, startIndex)) != -1) Int s_start = rtb.SelectionStart, startIndex = 0, index Public static void Find(RichTextBox rtb, String word, Color color) All you need is 3 buttons and two textboxes and one richtextbox in addition to whatever other controls you already have in your program. Just copy and paste it into your program. I post this here for any programmer who feels they can use it. It's not the find methods Microsoft talks about in their page on how work with richtextboxes, but it works. I edited this question to show that I figured out how to do it.
The Third button10_Click is for replacing the text found with some other text
The second button6_Click is for finding the next instance of that text. The first button5_Click is for Finding the text in the richtextbox. Private void button10_Click(object sender, EventArgs e) of texxtBox2 which is the replacement text. This replaces the selected text in the richtextbox with the contents Do you want to continue the search from the top of the document?", "Message", MessageBoxButtons.YesNo) Įlse if (dialogResult = DialogResult.No) Private void button6_Click(object sender, EventArgs e)ĭialogResult dialogResult = MessageBox.Show( "Larry's Journal has finished searching through the document. does not start over, it keeps searching from where it found the
#WORD RICH TEXT CONTENT CONTROL GRAYED OUT CODE#
same as the previous code for button5_Click except currentPos restart the method after resetting the indicator (start + currentPos, ) ĬurrentPos = start + currentPos + Then I have Three events tied to buttons like this private void button5_Click(object sender, EventArgs e) Public int currentPos = 1 // this is so currentPos does not loose its value I have this code for finding text in the Rtf box and highlighting the text.