请教组合框检索的问题?

bear1201 2006-04-17 10:09:20
有个录入窗口,里面有一个组合框,本身他作为一个选择框,下拉有很多内容,这样一个个看很难找到。我想在组合框中如果写了简单的内容,如果包含此内容的数据会显示出来。但是如果是没有那么就作为新记录,出来新的录入界面。
...全文
109 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
bear1201 2006-04-17
  • 打赏
  • 举报
回复
我把of123()的代码加上了,但是运行的时候没有效果,是不是也要设置什么属性才可以呀
killl 2006-04-17
  • 打赏
  • 举报
回复
学了
of123 2006-04-17
  • 打赏
  • 举报
回复
中文,试试:
Private Declare Function SendMessagebyString Lib _
"user32" Alias "SendMessageA" (ByVal hWND As Long, _
ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As String) As Long

Private Const LB_FINDSTRINGEXACT = &H1A2 '在 ListBox 中精确查找
Private Const CB_FINDSTRINGEXACT = &H158 '在 ComboBox 中精确查找
Private Const LB_FINDSTRING = &H18F '在 ListBox 中模糊查找
Private Const CB_FINDSTRING = &H14C '在 ComboBox 中模糊查找

Private Combo1_Change()
Dim n As Long

n = SendMessagebyString(Combo1.hWnd, CB_FINDSTRING, -1, Combo1.Text)
If n >= 0 Then Combo1.ListIndex = n

End Sub
of123 2006-04-17
  • 打赏
  • 举报
回复
'组合框列表增量查找(英文好用)
Public Sub ComboIncrementalSearch(cbo As _
ComboBox, KeyAscii As Integer)
Static dTimerLast As Double
Static sSearch As String
Static hWndLast As Long
Dim nRet As Long
Const MAX_KEYPRESS_TIME = 0.5
' Weed out characters that are not scanned
If (KeyAscii < 32 Or KeyAscii > 127) _
Then Exit Sub
If (Timer - dTimerLast) < _
MAX_KEYPRESS_TIME And hWndLast = _
cbo.hWnd Then
sSearch = sSearch & Chr$(KeyAscii)
Else
sSearch = Chr$(KeyAscii)
hWndLast = cbo.hWnd
End If
' Search the combo box
nRet = SendMessage(cbo.hWnd, _
CB_FINDSTRING, -1, ByVal sSearch)
If nRet >= 0 Then
cbo.ListIndex = nRet
End If
KeyAscii = 0
dTimerLast = Timer
End Sub
of123 2006-04-17
  • 打赏
  • 举报
回复
中文比较麻烦。

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧