怎么才能实现在combobox中输入数据的时候,可以自动查找相关的内容
比如:
现在combobox中有
111111
121212
23321
12432
那么我在输入1的时候就显示111111和121212和12432这三条数据

解决方案 »

  1.   

    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