Click here to Skip to main content
16,015,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi i have a rich text box if there is 10 sentences in rich text box arrange line by line and i want to find a specific word write in another text box.when i click on button then i want to highlight all search word of first line from rich text box and then when i click on button second time i want to highlight all search words from second line of rich text box.

i am using this code it works .it highlights search word on every click but i want when i click on button it search one line if there are 2 specific words in line one so highlight 2 words.

C#
int textEnd = txtshowfile.TextLength;
                int index = 1;
                int prevIndex = Convert.ToInt16(txtshowfile.Tag);
                int lastIndex = txtshowfile.Text.LastIndexOf(txtsearchgerman.Text);
                txtshowfile.SelectionBackColor = Color.Red;
                prevIndex = txtshowfile.Text.IndexOf(txtsearchgerman.Text, prevIndex + 1);
                txtshowfile.Tag = prevIndex;
                index = prevIndex;
                if (prevIndex < 0)
                {
                    MessageBox.Show("all german words are compare");                    
                }
                else
                {
                    txtshowfile.Find(txtsearchgerman.Text, index, textEnd, RichTextBoxFinds.None);
                    txtshowfile.SelectionBackColor = Color.Yellow;
                    index = txtshowfile.Text.IndexOf(txtsearchgerman.Text, index) + 1;
                    flag1++;
                }
>


i am new in coding.


Thanks in Advance.
Posted
Updated 23-Jan-12 23:55pm
v6

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900