问题描述
在VB.Net的表格中,我有两个文本框。
第一个文本框包含一行文字快速的棕色狐狸跳过一只懒狗
在第二个文本我想要输入相同的东西。
我的问题是当我在第二个文本框中键入文本时,第一个文本框中的文本应该逐个单词突出显示或加下划线。
示例
快速的棕色狐狸跳过一只懒狗
---
快速的棕色狐狸跳过一只懒狗
-----
如果我输入the,那么the应突出显示或加下划线。
接下来,如果我输入quick,那么quick上方应突出显示或加下划线。像这样它应该一直持续到最后。
我尝试过:
textbox1.cocus
RichTextBox1.SelectionStart = 0
RichTextBox1.SelectionLength = RichTextBox1.Text.Length
RichTextBox1.SelectionColor = Color。黑色
RichTextBox1.SelectionFont =新字体(RichTextBox1.SelectionFont,FontStyle.Regular)
RichTextBox1.SelectionStart = 0
RichTextBox1.SelectionLength = array (0).Length
RichTextBox1.SelectionColor = Color.Green
RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont,FontStyle.Underline)
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)
这篇关于键入时突出显示文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!