这是找到的能够实现类似功能的组合框的代码,改动一下能够实现。
' Enable extended matching to any type combobox control
'
' Extended matching means that as soon as you type in the edit area
' of the ComboBox control, the routine searches for a partial match 
' in the list area and highlights the characters left to be typed.
'
' To enable this capability you have only to call this routine
' from within the KeyPress routine of the ComboBox, as follows:
'
' Private Sub Combo1_KeyPress(KeyAscii As Integer)
'    ComboBoxExtendedMatching Combo1, KeyAscii
' End SubSub ComboBoxExtendedMatching(cbo As ComboBox, KeyAscii As Integer, _
    Optional CompareMode As VbCompareMethod = vbTextCompare)
    Dim index As Long
    Dim Text As String
    
    ' if user pressed a control key, do nothing
    If KeyAscii <= 32 Then Exit Sub
    
    ' produce new text, cancel automatic key processing
    Text = Left$(cbo.Text, cbo.SelStart) & Chr$(KeyAscii) & Mid$(cbo.Text, _
        cbo.SelStart + 1 + cbo.SelLength)
    KeyAscii = 0
    
    ' search the current item in the list
    For index = 0 To cbo.ListCount - 1
        If InStr(1, cbo.List(index), Text, CompareMode) = 1 Then
            ' we've found a match
            cbo.ListIndex = index
            Exit For
        End If
    Next
    
    ' if no matching item
    If index = cbo.ListCount Then
        cbo.Text = Text
    End If
    
    ' highlight trailing chars in the edit area
    cbo.SelStart = Len(Text)
    cbo.SelLength = 9999
    
End Sub

解决方案 »

  1.   

    refer to http://www.mvps.org/vbnet/index.html?code/fileapi/recursive.htm
      

  2.   

    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _
        hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
        lParam As Any) As LongConst LB_FINDSTRING = &H18F
    Const LB_FINDSTRINGEXACT = &H1A2
    Const CB_FINDSTRING = &H14C
    Const CB_FINDSTRINGEXACT = &H158' 在combobox或者listbox中查找匹配项
    ' 返回索引号,没有找到返回-1Function ListBoxFindString(ctrl As Control, ByVal search As String, _
        Optional startIndex As Long = -1, Optional ExactMatch As Boolean) As Long
        Dim uMsg As Long
        If TypeOf ctrl Is ListBox Then
            uMsg = IIf(ExactMatch, LB_FINDSTRINGEXACT, LB_FINDSTRING)
        ElseIf TypeOf ctrl Is ComboBox Then
            uMsg = IIf(ExactMatch, CB_FINDSTRINGEXACT, CB_FINDSTRING)
        Else
            Exit Function
        End If
        ListBoxFindString = SendMessage(ctrl.hWnd, uMsg, startIndex, ByVal search)
    End Function
      

  3.   

    本人已经做好了一个,想要的加我QQ:988112,功能和VB的APIView一样,而且,部分函数还有例子和详细说明。当然,我要分的,给多少随便。在加我QQ时候请注明:我要WinapiView。还有就是别忘了把你的E-mail也一同给我。