[英]vb.net richtextbox text selection from a to b
I want to select text in richtextbox from point a to b like in html format code red> to /red> soo that would be like this: This is a red>message/red> that means it should select from point a that is red> to point b that is /red> then the message word will be selected how can i do that? 我想在richtextbox中从点a到b选择文本,例如html格式代码red>到/ red>这样:这是一个red> message / red>,这意味着它应该从点a中选择一个红色>指向是/ red的b,然后将选择消息单词,我该怎么做? Thanks. 谢谢。
My latest code that i tried: 我尝试的最新代码:
If RichTextBox1.Text.Contains("<red>") Then
RichTextBox1.SelectionStart = RichTextBox1.Find("<red>").ToString
RichTextBox1.SelectionLength = RichTextBox1.Find("</red>").ToString
MessageBox.Show("Format DETECTED!")
End If
RichTextBox1.SelectionColor = Color.Red
Try it. 试试吧。
If RichTextBox1.Text.Contains("<red>") Then
RichTextBox1.SelectionStart = CInt(RichTextBox1.Find("<red>").ToString)
RichTextBox1.SelectionLength = CInt(RichTextBox1.Find("</red>").ToString)
RichTextBox1.Select(RichTextBox1.Find("<red>") + "<red>".Length, RichTextBox1.Find("</red>") - (RichTextBox1.Find("<red>") + "<red>".Length))
RichTextBox1.SelectionColor = Color.Red
MessageBox.Show("Format DETECTED!")
End If
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.