现在我把他的STYLE 设置为SIMPLE COMBO,装载窗体的时候就把数据从数据库总搜索出来,显示在他的列表中,现在我想根据我在COMBO 上面输入的字串自动INDEX到匹配的LISTITEM上,并且下面的LISTITEMS从这个LISTITEM开始显示,之前的自动隐藏。不知有无高手相告

解决方案 »

  1.   

    在change事件中加入判断代码,不过,如果数据量大的时候可能有延迟感
      

  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 Long
    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 = iLeftOffsString = CStr(Left(Combo1.Text, iStart))
    Combo1.ListIndex = SendMessage(Combo1.hwnd, &H14C, -1, ByVal CStr(Left(Combo1.Text, iStart)))
     
    If Combo1.ListIndex = -1 Then iLeftOff = Len(sString): Combo1.Text = sString
    If Combo1.Text <> "" Then SendMessage Combo1.hwnd, &H14F, True, 0Combo1.SelStart = iStart
    Combo1.SelLength = 0
    iLeftOff = 0End Sub
    Private Sub Form_Load()
    Dim i As Long
    For i = 1 To 500
    Randomize
    Combo1.AddItem Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97) & Chr(Int(Rnd * 26) + 97)
    Next
    Combo1.Text = ""
    End Sub