Click here to Skip to main content
15,905,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In VB.Net in a form I have two text boxes.
First textbox contains a line of text "the quick brown fox jumps over a lazy dog"
in second text same thing i want to type.
My question is when i type the text in second textbox, the text available in first textbox should be highlighted or underlined word by word.

example

the quick brown fox jumps over a lazy dog
---
the quick brown fox jumps over a lazy dog
-----
if i type "the" then above "the" should be highlighted or underlined.
next if i type "quick" then above "quick" should be highlighted or underlined. like this it should continue till the end.

What I have tried:

textbox1.cocus
RichTextBox1.SelectionStart = 0
RichTextBox1.SelectionLength = RichTextBox1.Text.Length
RichTextBox1.SelectionColor = Color.Black
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Regular)
RichTextBox1.SelectionStart = 0
RichTextBox1.SelectionLength = array(0).Length
RichTextBox1.SelectionColor = Color.Green
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont, FontStyle.Underline)
Posted
Updated 14-Dec-18 0:45am
Comments
RickZeeland 15-Dec-18 4:47am    
Did you downvote my solution ? if so I would like to know why ...

1 solution

I can recommend the Fast Colored TextBox which has a lot of interesting options, including diff options and a document map option: Fast Colored TextBox for Syntax Highlighting[^]
On GitHub you can find VB.NET code for testing purposes: GitHub - PavelTorgashov/FastColoredTextBox: Fast Colored TextBox for Syntax Highlighting. The text editor component for .NET.[^]
 
Share this answer
 
v2

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