Click here to Skip to main content
15,067,832 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi All,
I am displaying the word document in to textbox.
Now i want to highlight the search text in muliti line textbox.
Posted
Updated 17-May-11 20:48pm
v3

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;
You may need to add
myTextBox.ScrollToCaret();
to ensure that the selected text is visible.
   
Comments
   
Correct, a 5.
--SA
<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>
   

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




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900