我要做一个类似msdn中搜索用的combobox,如何实现?(急,再线等待)

flyfan 2003-09-30 09:36:12
我要做一个类似msdn中搜索用的combobox,就是当用户输入字符后可以自动找到所匹配的text,text来自数据库,请问用datacombo和dbcombo那个能实现呢
,msdn中说dbcombo支持自动搜索,为何我的不行呢,是否要自己写代码?xiexie~!
...全文
130 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
chanet 2003-10-01
  • 打赏
  • 举报
回复
change/keypress 事件
rainstormmaster 2003-10-01
  • 打赏
  • 举报
回复
msdn中说dbcombo支持自动搜索,为何我的不行呢,是否要自己写代码?xiexie~!

绑定字段了吗?
northwolves 2003-10-01
  • 打赏
  • 举报
回复
combo就可以:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Sub Combo1_Change()
Dim iStart As Integer
Dim sString As String
Static iLeftOff As Integer

iStart = 1
iStart = Combo1.SelStart

If iLeftOff <> 0 Then Combo1.SelStart = iLeftOff: iStart = iLeftOff

sString = CStr(Left(Combo1.Text, iStart))
Combo1.ListIndex = SendMessage(Combo1.hwnd, &H14C, -1, ByVal CStr(Left(Combo1.Text, iStart)))

If Combo1.ListIndex = -1 Then iLeftOff = Len(sString): Combo1.Text = sString
If Combo1.Text <> "" Then SendMessage Combo1.hwnd, &H14F, True, 0

Combo1.SelStart = iStart
Combo1.SelLength = 0
iLeftOff = 0

End Sub
Private Sub Form_Load()
Dim i As Long
For i = 1 To 500
Randomize
Combo1.AddItem Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97)
Next
Combo1.Text = ""
End Sub

1,453

社区成员

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

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