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://ybzwz.com/article/hcgpjd.html