欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【.NET中为组合框添加自动查询功能】,下面是详细的分享!
.NET中为组合框添加自动查询功能
Private Sub AutoCompleteKeyUp(ByVal Combo As ComboBox, ByVal e As KeyEventArgs)
Dim strTyped As String
Dim intFoundIndex As Integer
Dim objFoundItem As Object
Dim strFoundText As String
Dim strAppendText As String
'忽略特殊键
Select Case e.KeyCode
Case Keys.Back, Keys.Left, Keys.Right, Keys.Up, Keys.Down, Keys.Delete, Keys.CapsLock
Return
End Select
'在查询列表中找到
strTyped=Combo.Text
intFoundIndex=Combo.FindString(strTyped)
If intFoundIndex >=0 Then
objFoundItem=Combo.Items(intFoundIndex)
strFoundText=Combo.GetItemText(objFoundItem)
strAppendText=strFoundText.Substring(strTyped.Length)
Combo.Text=strTyped & strAppendText
Combo.SelectionStart=strTyped.Length
Combo.SelectionLength=strAppendText.Length
End If
End Sub
Private Sub AutoCompleteLeave(ByVal Combo As ComboBox)
Dim intFoundIndex As Integer
intFoundIndex=Combo.FindStringExact(Combo.Text)
Combo.SelectedIndex=-1
Combo.SelectedIndex=intFoundIndex
End Sub
Private Sub ComboBox1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ComboBox1.KeyUp
AutoCompleteKeyUp(ComboBox1, e)
End Sub
Private Sub ComboBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.Leave
AutoCompleteLeave(ComboBox1)
End Sub
以上所分享的是关于.NET中为组合框添加自动查询功能,下面是编辑为你推荐的有价值的用户互动:
相关问题:access窗体中添加自动查询功能
答:使用部门文本框改为组合框 在使用部门组合框的on change事件中写以下代码: 使用部门.RowSource = "select 使用场所 from 使用场所表 where 使用场所 like '*" & 使用场所.Text & "*'"使用部门.Dropdown >>详细
相关问题:怎样给组合框增加条目
答:当你在一个组合框中输入时,可能会遇到一个列表中没有的记录,如何在输入后能自动添加进去呢? 下面就讲讲这个不在列表中的事件命令应该怎么写. 1,实现这一效果,你首先应该把组合框的"行来源类型"定为:表/查询,另外在"限于列表"属性设为:是 2,在"不... >>详细
相关问题:access窗体中用组合框建立查询
答:检查组合框属性表--其他选项卡下名称是否是“职务”;组合框的列数和绑定列是否正确。 另外,“职务”字段下设置条件改完整写法为“[Forms]![窗体1]![职务].value”或“[Forms]![窗体1]![职务].text”试试。 把你的数据库传上来,看问题出在哪里。 >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
