问题描述
我正在使用visual studio 2010(vb.net- windows窗体)。
我有一个文本框,其中包含数字的日期和字符串。
i需要突出显示该文本框中的所有数值和日期,并需要一个选项来更改鼠标单击时的值。 (即字符串内容没有变化)
例如
让文本框中的值为
我的名字是Sidharth。我26岁。我的dob是22/03/1990
当值加载到文本框时
它应显示为
我的名字是Sidharth。我是 26岁。我的dob 22/03/1990
鼠标点击或鼠标焦点我需要一个更改选项。
I am using visual studio 2010 (vb.net- windows form ).
I have a text box which consist of number's date and string.
i need to highlight all numeric values and date in that text box and need an option to change the value on mouse click . (ie No changes in string content)
for example
let value in text box be
"Hi my name is Sidharth. I'm 26 yr old . my dob is 22/03/1990"
when value is loaded to text box
it should display as
"Hi my name is Sidharth. I'm 26 yr old . my dob is 22/03/1990"
on mouse click or mouse focus i need an option to change.
Dim TextToFormat As Integer
Dim TextFormat As String
TextFormat = 1
TextToFormat = "Hi my name is Sidharth. I'm 26 yr old . my dob is 22/03/1990"
Dim count As New List(Of Integer)()
For i As Integer = 0 To rText.Text.Length - 1
If rText.Text.IndexOf(TextToFormat, i) <> -1 Then
'If the word is found add the index to the list
count.Add(rText.Text.IndexOf(TextToFormat, i))
End If
Next
Try
For i As Integer = 0 To count.Count - 1
rText.[Select](count(i), TextToFormat.Length)
Select Case TextFormat
Case 1
rText.SelectionFont = New Font(rText.Font.FontFamily, rText.Font.Size, FontStyle.Italic)
Case 2
rText.SelectionFont = New Font(rText.Font.FontFamily, rText.Font.Size, FontStyle.Italic)
End Select
count.RemoveAt(i)
Next
Catch
End Try
在此搜索txtbox中的文本并格式化文本
bt我需要获取所有数值。
in this im searching a text in txtbox and formatting the text
bt i need to get all numerical values.
推荐答案
这篇关于突出显示文本框中的数值。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!