如何在C#.net的Web应用程序的文本框中突出显示搜索文本 [英] How to highlight search text in textbox in web application in C#.net

查看:96
本文介绍了如何在C#.net的Web应用程序的文本框中突出显示搜索文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在将word文档显示在文本框中.
现在,我要突出显示多行文本框中的搜索文本.

Hi All,
I am displaying the word document in to textbox.
Now i want to highlight the search text in muliti line textbox.

推荐答案

您可以应用于文本框的唯一突出显示是选择-就像您双击一个文本框一样.字-没有特定的突出显示.为了使它正常工作,您需要一个RichTextBox.

在TextBox中选择特定文本很容易:
The only highlight you can apply to a TextBox is Selection - just as if you had double clicked a word - there is no specific Highlight. For that to work properly, you need a RichTextBox.

To select specific text in a TextBox is easy:
myTextBox.SelectionStart = indexOfFirstCharacterToSelect;
myTextBox.SelectionLength = numberOfCharactersToSelect;

您可能需要添加

myTextBox.ScrollToCaret();

,以确保所选文本可见.

to ensure that the selected text is visible.


< pre>< pre>< pre>< code>< code> ;< code></code></code></code></code</pre></pre</pre>< b>< b< b> b> b< b>小<小>小<小<大>大& gt;&> < a href ="></a>< a href ="></a>< a href ="></a>< a href ="> ;</a>< a href ="></a>< a href ="></a>< a href ="></a>< a href ="></a>< a href ="></a></big></big></small></small></small> ;</b</b</b</b></b>
<pre><pre><pre><code><code><code><code></code></code></code></code></pre></pre></pre><b><b><b><b><b><small><small><small><big><big>&gt;&gt;&gt;&amp;<a href=""></a><a href=""></a><a href=""></a><a href=""></a><a href=""></a><a href=""></a><a href=""></a><a href=""></a><a href=""></a></big></big></small></small></small></b></b></b></b></b>


这篇关于如何在C#.net的Web应用程序的文本框中突出显示搜索文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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