Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# WinForm
Hi i have a two text box one is multi line text box as "txtshowfile" and another text box is "txtsearch". Suppose In txtshowfile there are 10 sentences written in line by line now i wrote a word in txtsearch box and click a button event event so i want in
txtshow file if the word is found then specific word is highlighted and if in a line one or more words are found then all are highlighted.
Please help me out.
 
Thanks in Advance.
Posted 26-Jan-12 23:12pm
Edited 28-Jan-12 2:41am
v2
Comments
BillWoodruff at 28-Jan-12 10:55am
   
Appears to be an exact duplicate of a question asked yesterday by "soothingshruti:" http://www.codeproject.com/Answers/320694/how-to-find-a-specif-word-in-a-richtext-box-libe-b#answer2
 
You both in the same class ? :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If you take any editor as like FCKD editor then u can get that kind of feature/
or if u want to highligh on the Lebel text then also possible
 
..i dont know text box has such kind of feature
  Permalink  
Comments
shrivastava.mayank at 27-Jan-12 4:34am
   
it is possible from rich text box ?
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

string search = txtsearchgerman.Text;
                if (i > 0)
                {
                    gerendindex = gerendindex + rtbgermanfile.Lines[k].Length + 1;
                }
                while (m != -1)
                {
                    m = rtbgermanfile.Lines[i].IndexOf(search, m);
                    if (m != -1)
                    {
                        if (i == 0)
                        {
                            rtbgermanfile.SelectionStart = m;
                            rtbgermanfile.SelectionLength = search.Length;
                            rtbgermanfile.SelectionColor = Color.Red;
                            m = m + search.Length;
                            flag1++;
                        }
                        else
                        {
                            rtbgermanfile.SelectionStart = m + gerendindex;
                            rtbgermanfile.SelectionLength = search.Length;
                            rtbgermanfile.SelectionColor = Color.Red;
                            m = m + search.Length;
                            flag1++;
                        }
                    }
                }
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 400
1 Sergey Alexandrovich Kryukov 329
2 Afzaal Ahmad Zeeshan 264
3 BillWoodruff 245
4 CPallini 195
0 OriginalGriff 5,560
1 DamithSL 4,476
2 Maciej Los 3,942
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,175


Advertise | Privacy | Mobile
Web04 | 2.8.141216.1 | Last Updated 28 Jan 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100