如何在文本框中逐行查找每个单击中的特定单词 [英] how to find a specific word in each click line by line in text box

查看:91
本文介绍了如何在文本框中逐行查找每个单击中的特定单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本框,一个是"txtshowfile"的多行文本框,另一个是"txtsearch".假设在txtshowfile中一行一行写着10个句子,现在我在txtsearch框中写了一个单词,然后单击按钮事件事件,所以我想输入
txtshow文件(如果找到该单词)则突出显示特定单词,如果在一行中找到一个或多个单词,则突出显示所有单词.
请帮帮我.

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.

推荐答案

如果您像FCKD编辑器那样使用任何编辑器,则您可以获得这种功能/
或者,如果您想突出显示Lebel文字,也可以

..我不知道文本框具有这种功能
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


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++;
                        }
                    }
                }


这篇关于如何在文本框中逐行查找每个单击中的特定单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆