资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net文本框高亮 vb清楚文本框代码

VB.NET 的文本框问题。在失去文本框的焦点之后,如果用textbox1.focus()的话,光

用一个全局变量c保存textbox1.SelectionStart,然后在textbox1.focus的代码后,将textbox1.SelectionStart设为c

创新互联建站是一家以网络技术公司,为中小企业提供网站维护、成都做网站、成都网站制作、成都外贸网站建设、网站备案、服务器租用、空间域名、软件开发、小程序开发等企业互联网相关业务,是一家有着丰富的互联网运营推广经验的科技公司,有着多年的网站建站经验,致力于帮助中小企业在互联网让打出自已的品牌和口碑,让企业在互联网上打开一个面向全国乃至全球的业务窗口:建站联系电话:028-86922220

VB.net RichTextBox怎么实现关键字高亮?

TextChanged事件中捕获就可以。让后选择关键字文本定义颜色,如果关键词较多,并且有格式化文本要求,可以在程序外部定义Json或xml格式化定义文档,RichTextBox调用后根据定义格式化文本就好了。

vb.net textbox1.selectAll()

SelectAll其实已经把所有文本选上了,只不过没有高亮而已,但是你可以自己模拟一个选择高亮:

r.SelectAll()

r.SelectionColor = System.Drawing.Color.White ' 文字色

r.SelectionBackColor = System.Drawing.Color.Navy ' 背景色

VB.NET关键字上色/高亮问题。

Private Sub RichTextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RichTextBox1.TextChanged

Dim pos = RichTextBox1.SelectionStart

Dim i As String = Regex.Matches(RichTextBox1.Text, "\bDim\b").ToString

RichTextBox1.SelectAll

RichTextBox1.SelectionColor = Color.Black

If Regex.IsMatch(RichTextBox1.Text, "\bDim\b") = True Then

For Each mat As Match In Regex.Matches(RichTextBox1.Text, "\bDim\b")

RichTextBox1.SelectionStart = mat.Index

RichTextBox1.SelectionLength = mat.Length

RichTextBox1.SelectionColor = Color.YellowGreen

Next

End If

RichTextBox1.SelectionStart = pos

RichTextBox1.SelectionLength = 0

End Sub

我做了一个更详细的正则:

Friend Keys As String =

"\b(#Const|#If|Then|#Else|#Region|Delegate|Namespace|Class|End|Firend|Partial|Module|Interface|Enum|Shared|Overrides|Overloads|Structure|Let|Const|Dim|As|Private|Public|New|Static|Option|Private|Module|IsArray|IsDate|IsEmpty|IsError|IsMissing|IsNull|IsNumeric|IsObject|TypeName|VarType|Me|Option|Explicit|Mod|Like|Is|Not|And|Or|Xor|Eqv|Imp|Clear|Error|Raise|Error|Err|CVErr|On|Error|Resume|IsError|Collection|Add|Remove|Item|DDB|SLN|SYD|FV|Rate|IRR|MIRR|NPer|IPmt|Pmt|PPmt|NPV|PV|Do|Loop|For|Next|For|Each|Next|While|Wend|With|Choose|If|Then|Else|Select|Case|Switch|Call|Function|Property|Get|Property|Let|Property|Set|Sub|Date|Now|Time|DateAdd|DateDiff|DatePart|DateSerial|DateValue|TimeSerial|TimeValue|Date|Time|Timer|CBool|CByte|CCur|CDate|CDbl|CDec|CInt|CLng|CSng|CStr|CVar|CVErr|Fix|Int|Boolean|Byte|Currency|Date|Double|Integer|Long|Object|Single|String|Object|Atn|Cos|Sin|Tan|Exp|Log|Sqr|Randomize|Rnd|Abs|Sgn|Fix|Int|IsArray|Array|Option|Base|Dim|Private|Public|ReDim|Static|LBound|UBound|Erase|ReDim|DeleteSetting|GetSetting|GetAllSettings|SaveSetting|Chr|Format|LCase|UCase|DateSerial|DateValue|Hex|Oct|Format|Str|CBool|CByte|CCur|CDate|CDbl|CDec|CInt|CLng|CSng|CStr|CVar|CVErr|Fix|Int|Day|Month|Weekday|Year|Hour|Minute|Second|Asc|Val|TimeSerial|TimeValue|StrComp|StrConv|Format|LCase|UCase|Space|String|Len|Format|LSet|RSet|InStr|Left|LTrim|Mid|Right|RTrim|Trim|Option|Compare|Asc|Chr|AppActivate|Shell|SendKeys|Beep|Command)\b"

vb.net 高亮度显示文本

选中就是高亮,首先得到你找到的文本字符的起始位置和长度,然后

TextBox.Select(start,length)

TextBox.SelectionStart = start

TextBox.SelectionLength = length

vb.net listview控件怎样写代码,选择指定行,然后高亮!

'n为设置要选择的行,并高亮显示

ListView1.Items(n).Selected = True

ListView1.Focus()


分享题目:vb.net文本框高亮 vb清楚文本框代码
转载来于:http://cdkjz.cn/article/hiiddg.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220