资讯

精准传达 • 有效沟通

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

vb.net输入自动补全的简单介绍

vb 中 关于ComboBox控件的自动补全

只要在设计时设置ComboBox的Sort=True,Style=1,就可以实现自动补全功能了.

10年积累的网站设计制作、做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站制作后付款的网站建设流程,更有政和免费网站建设让你可以放心的选择与我们合作。

vb.net 实现ComboBox输入字符自动补充字符

Public Sub AutoComplete(ByVal cmb As ComboBox, ByVal e As System.Windows.Forms.KeyPressEventArgs)

If cmb.DataSource Is Nothing Then

Return

End If

If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Enter) Then

Return

End If

Dim strFindStr As String = ""

If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Back) Then

If (cmb.SelectionStart = cmb.Text.Length) Then

If cmb.Text.Length  0 Then

strFindStr = cmb.Text.Substring(0, cmb.Text.Length - 1)

End If

Else

If cmb.SelectionStart  0 Then

strFindStr = cmb.Text.Substring(0, cmb.SelectionStart - 1)

End If

End If

e.Handled = False

Else

If (cmb.SelectionLength = 0) Then

strFindStr = cmb.Text + e.KeyChar

Else

If (cmb.SelectionStart = cmb.Text.Length) Then

strFindStr = e.KeyChar

Else

If cmb.SelectionStart  0 Then

strFindStr = cmb.Text.Substring(0, cmb.SelectionStart - 1) + e.KeyChar

Else

strFindStr = e.KeyChar

End If

End If

End If

End If

Dim intIdx As Integer = -1

Dim dv As DataView

If TypeOf (cmb.DataSource) Is DataTable Then

dv = CType(cmb.DataSource, DataTable).DefaultView

If strFindStr  "" Then

dv.RowFilter = cmb.DisplayMember  " Like '%"  strFindStr  "%'"

Else

dv.RowFilter = ""

End If

cmb.DataSource = dv

cmb.SelectedIndex = -1

cmb.Text = strFindStr

Else

dv = CType(cmb.DataSource, DataView)

If strFindStr  "" Then

dv.RowFilter = cmb.DisplayMember  " Like '%"  strFindStr  "%'"

Else

dv.RowFilter = ""

End If

cmb.DataSource = dv

cmb.SelectedIndex = -1

cmb.Text = strFindStr

End If

cmb.SelectionStart = strFindStr.Length

e.Handled = True

End Sub

Private Sub comboBox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles comboBox1.KeyPress

AutoComplete(sender, e)

End Sub

vb.net 如何让自己写的代码也有代码的提示

当然可以

例如,你有一个方法,假如名叫Sort,没有参数,这样呢,就在

Sub Sort()的上面输入三个单引号(就是注释的那个),就会出现xml注释:

''' summary

'''

''' /summary

Sub Sort()

End Sub

在summary下面一行写“排序数组”(没有引号),这时,调用方法的时候,就有像你图上的那样子的代码提示


网页标题:vb.net输入自动补全的简单介绍
分享地址:http://cdkjz.cn/article/hcgpjd.html
多年建站经验

多一份参考,总有益处

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

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

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220