突出显示在girdview或文本框中搜索的单词/短语 [英] Highlight searched word/phrase in girdview or textbox
本文介绍了突出显示在girdview或文本框中搜索的单词/短语的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果用户搜索数据库中的单词,则结果将出现在gridview或textbox中。
现在我想将搜索到的文本(特定文本)突出显示到gridview或文本框中。
我正在使用Windows Formm。
if user search a word in database then the result will come in gridview or textbox.
now i want to highlight searched text (specific text) into gridview or textbox.
I am using windows Formm.
推荐答案
Hi Muhamed Faizan Khan,
我担心你会必须写一些代码。
一些提示:
想想亮点对你意味着什么(更改ForeColor
?)
使用RichTextBox
而不是TextBox
- 更好地突出显示能力 - 你会如何在TextBox上做到这一点?
如果我猜对了,可能很难突出GridView中的特定文本(单元格的一部分) - OwnerDrawing对于初学者来说没什么...
下一个问题:如何在控件中找到要突出显示的文本(可能会计算所有相关控件(文本部分)的起始索引列表?
如果你有 - 只需将突出显示代码应用于所有找到的文本部分。
当然 - 创建一个重置功能,轻松不突出显示。
快乐的编码!
亲切的问候
Johannes
Hi Muhamed Faizan Khan,
I fear you will have to write some code.
Some hints:
Think about what "highlight" means for you (changeForeColor
?)
UseRichTextBox
instead ofTextBox
- better "highlighting" capabillities - how would you do that on a TextBox?
If I guess right, it could be difficult to highlight specific text (parts of a cell) within a GridView - OwnerDrawing is nothing for beginners...
Next question: how to find the texts to highlight in the controls (maybe calcualte a list of start-end indices for all involved controls (text-parts)?
If you got that - just apply your "highlighting" code to all found text-parts.
And of course - Create a "reset" function for easy "un-highlight".
Happy coding!
Kind Regards
Johannes
这篇关于突出显示在girdview或文本框中搜索的单词/短语的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文