- Open the last C# project
- Add a TextBox and a Button
- I change the button's name as Search
- Double click on the search button and put the following codes.
- Now run your programm
- You can see the letters was highlighted, I typed
- You can change the Events of the text box
- Goto propeties -> Events
- Search for a KeyPress event.
- Double click on it and goto code part of it.
- Copy the all code of search button and paste it in KeyPress event.
- Now you don'd need the search button. If you type a key, it will search for it.
int index = 0; string temp = GetRichBox().Text; GetRichBox().Text = ""; GetRichBox().Text = temp; while (index < richTextBox1.Text.LastIndexOf(textBox1.Text)) { richTextBox1.Find(textBox1.Text, index, richTextBox1.TextLength, RichTextBoxFinds.None); richTextBox1.SelectionBackColor = Color.GreenYellow; index = richTextBox1.Text.IndexOf(textBox1.Text, index) + 1; }
Next post I will show you how remove the tabs.
No comments:
Post a Comment