|
|
|
|
|
Dicas
|
|
Visual Basic (ActiveX/Controles/DLL)
|
|
|
Título da Dica: Localizar no ComboBox em tempo de digitação
|
|
|
|
Postada em 21/10/2002 por Carlos Sergio
cstintori@hotmail.com
#If Win32 Then 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 #Else Private Declare Function SendMessage Lib "User" _ (ByVal hWnd As Integer, ByVal wMsg As Integer, _ ByVal wParam As Integer, lParam As Any) As Long #End If
Private Sub Form_Load()
Combo1.AddItem "Adriana" Combo1.AddItem "Ricardo"
End Sub
'No KeyPress da ComboBox use o código:
Private Sub Combo1_KeyPress(KeyAscii As Integer) Dim CB As Long Dim FindString As String Const CB_ERR = (-1) Const CB_FINDSTRING = &H14C If KeyAscii < 32 Or KeyAscii > 127 Then Exit Sub If Combo1.SelLength = 0 Then FindString = Combo1.Text & Chr$(KeyAscii) Else FindString = Left$(Combo1.Text, Combo1.SelStart) & Chr$(KeyAscii) End If CB = SendMessage(Combo1.hWnd, CB_FINDSTRING, -1, ByVal FindString) If CB <> CB_ERR Then Combo1.ListIndex = CB Combo1.SelStart = Len(FindString) Combo1.SelLength = Len(Combo1.Text) - Combo1.SelStart End If KeyAscii = 0
End Sub
|
|
|
|
|