For I = 0 To Screen.FontCount - 1
cboFont.AddItem Screen.Fonts(I)
Next I
Combo的自动查询技术
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const CB_FINDSTRING = &H14C
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
End If
sString = CStr(Left(Combo1.Text, iStart))
Combo1.ListIndex = SendMessage(Combo1.hwnd, _
B_FINDSTRING, -1, ByVal CStr(Left( _
ombo1.Text, iStart)))
If Combo1.ListIndex = -1 Then
iLeftOff = Len(sString)
combo1.Text = sString
End If
Combo1.SelStart = iStart
iLeftOff = 0
End Sub
本文介绍了一种在Visual Basic中实现组合框自动查询的技术。通过使用API函数SendMessage发送CB_FINDSTRING消息来查找组合框列表中匹配的条目,并更新当前选中的项。此方法可以提高用户在大量选项中搜索所需项的效率。
2652

被折叠的 条评论
为什么被折叠?



