组合框自动展开
我想实现在组合框中输入内容后,自动出现下拉,就象很多网上的那样输入了用户名的前几位自动在下面出现了与之相关的内容,该怎么实现啊??我用了
me.combo1.dropdown但说没这种方法
--------------------编程问答-------------------- 可以用API:
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 Const CB_SHOWDROPDOWN = &H14F
Private Sub Command1_Click()
Call SendMessage(Combo1.hwnd, CB_SHOWDROPDOWN, 1, ByVal 0&)
End Sub --------------------编程问答-------------------- Private Sub Combo1_KeyPress(KeyAscii As Integer)
If KeyAscii=13 Then 'KeyAscii=13 '表示输入后按回车键
For i=0 To Combo1.ListCount-1
If Combo1.Text=Combo1.List(i) Then
msgbox "输入项已在组合框中"
Exit Sub
End if
Next i
msgbox "已成功添加输入项"
Combo1.AddItem Combo1.Text
End if
End Sub
--------------------编程问答-------------------- API我 运行不对
第二个可能是理解不对我 是想组合框自动展开 --------------------编程问答-------------------- Private Sub Command1_Click()
Combo1.SetFocus
SendKeys "{f4}"
End Sub
或者
SendMessage Combo1.hwnd, CB_SHOWDROPDOWN, True, 0 --------------------编程问答-------------------- API运行不对?不会啊,能说一下什么错误吗?
补充:VB , 基础类