在列表框中突出显示子字符串 [英] Highlighting Substring in listbox
本文介绍了在列表框中突出显示子字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,我只需要突出显示整个字符串的一部分:如果用户在文本框中输入Prop,则突出显示的输出将是
在字符串"Dependency property"中,我们只需要突出显示"Prop".请让我知道解决方案.
I need to Highlight only the Portion of that whole string for example:if user enters Prop in textbox the highlighted output will be
in String "Dependency property" word we need to highlight only "Prop".Please let me know the Solution.
推荐答案
您不能将不同的文本样式应用于TextBox
,则应考虑使用RichTextBox
.
You can''t apply different text styles to aTextBox
, you should consider using aRichTextBox
instead.
您不会回答我的问题:TextBox
或ListBox
.
我认为这与问题的标题和内容之间没有矛盾.您可能只是一件事.虽然我认为Olivier在TextBox
/RichTextBox
上的答案已经足够好了,但是对于ListBox
来说,您所需的文本呈现并不是那么容易实现.您可以创建自己的控件(可能从ListBox
派生)并对其进行自定义绘制.
—SA
You don''t answer my question:TextBox
orListBox
.
I think this is no a contradiction between title and body of the question. You probably meant just one thing. While I think the answer by Olivier onTextBox
/RichTextBox
is good enough, the text rendering you need is not so easy to achieve forListBox
. You can create your own control (probably derived fromListBox
) and custom-paint it.
—SA
这篇关于在列表框中突出显示子字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文