我的组合框里存的有数据,当我在组合框输数据时,组合框会自动显示以我输入的字母开头的匹配的组合框中数据,类似金山词霸中输入单词时,列表框中单词会自动显示相匹配的词?

解决方案 »

  1.   

    Private Sub Combo1_Change()    Dim i As Integer
        Dim f_rtn As Long
         List1.Clear
        For i = 0 To Combo1.ListCount - 1
           f_rtn = InStr(1, Combo1.List(i), Combo1.Text, 1)
           If f_rtn = 1 Then
               List1.AddItem (Combo1.List(i))
           End If
        Next i
    End Sub
      

  2.   

    '组合框列表增量查找
    Public Sub ComboIncrementalSearch(cbo As _
    ComboBox, KeyAscii As Integer)
    Static dTimerLast As Double
    Static sSearch As String
    Static hWndLast As Long
    Dim nRet As Long
    Const MAX_KEYPRESS_TIME = 0.5
    ' Weed out characters that are not scanned
    If (KeyAscii < 32 Or KeyAscii > 127) _
    Then Exit Sub
    If (Timer - dTimerLast) < _
    MAX_KEYPRESS_TIME And hWndLast = _
    cbo.hWnd Then
    sSearch = sSearch & Chr$(KeyAscii)
    Else
    sSearch = Chr$(KeyAscii)
    hWndLast = cbo.hWnd
    End If
    ' Search the combo box
    nRet = SendMessage(cbo.hWnd, _
    CB_FINDSTRING, -1, ByVal sSearch)
    If nRet >= 0 Then
    cbo.ListIndex = nRet
    End If
    KeyAscii = 0
    dTimerLast = Timer
    End Sub
      

  3.   

    据我所知要用到API
    但是,我看 wyxxzg77 的也可以你试试!
      

  4.   

    楼上说的很好,用DELPHI就简单了