请教一下,如何才能实现在一个组合框里输入文字时就进行筛选出只符合输入内容的列表,即是每当输入一个字就进行筛选一次,达到能快速选择组合框内容的值?
会的请写出代码或者将思路详细说明一下,谢谢!!!!!

解决方案 »

  1.   

    http://www.china-askpro.com/msg18/qa81.shtml
      

  2.   

    下面是一个列表框的例子,给你参考一下,在文本框中输入匹配列表中的内容时,实时高亮。
    其中search是个函数,用于搜索列表框控件中符合这个变元的项目。
    private sub txt_change()
    position=search(trim$(txt.Text))
    if position>=0 then
     list1.listindex=position
    else
     list1.listindex=-1
    endif
    end sub
      

  3.   

    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'组合框列表增量查找
    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