سورس AutoComplete for ComboBox به زبان ویژوال بیسیک 6


سورس AutoComplete for ComboBox به زبان ویژوال بیسیک 6

Private miSelStart As Integer
Private Sub Combo1_KeyDown(KeyCode As Integer, Shift As Integer)
    '<Delete>
    If KeyCode = 46 Then KeyCode = 0 'Disable the delete key

    miSelStart = Combo1.SelStart
End Sub

Private Sub Combo1_KeyPress(KeyAscii As Integer)    
    Dim lCnt       As Long 'Generic long counter
    Dim lMax       As Long
    Dim sComboItem As String 
    Dim sComboText As String 'Text currently in combobox
    Dim sText      As String 'Text after keypressed

    With Combo1
        lMax = .ListCount - 1 
        sComboText = .TEXT 
        sText = Left(sComboText, miSelStart) & Chr(KeyAscii)
        
        KeyAscii = 0 'Reset key pressed
        
        For lCnt = 0 To lMax
            sComboItem = .List(lCnt)
            
            If UCase(sText) = UCase(Left(sComboItem, _
                                         Len(sText))) Then
                .ListIndex = lCnt
                .TEXT = sComboItem
                .SelStart = Len(sText)
                .SelLength = Len(sComboItem) - (Len(sText))
                
                Exit For
            End If
        Next 'lCnt
    End With
End Sub

تماس با گیل دیتا call

مطالب مشابه


2019 © تمامی حقوق این وب‌سایت برای گیل دیتا محفوظ است.
انصراف
پشتیبانی آنلاین