|
-
Nov 15th, 1999, 01:06 AM
#1
Thread Starter
Addicted Member
I want to know if there is a property or something to make my combo box autocomplete the word I am typing with what it finds in the list...
Or am I doing something wrong ?
-
Nov 15th, 1999, 02:52 AM
#2
Sure thing:
Code:
Private Declare Function SendMessageStr Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const CB_FINDSTRING = &H14C
Private Sub Combo1_Change()
Dim lRetIndex As Long
lRetIndex = SendMessageStr(Combo1.hwnd, CB_FINDSTRING, -1, ByVal Combo1.Text)
If lRetIndex >= 0 Then Combo1.ListIndex = lRetIndex
End Sub
Regards,
------------------
Serge
Software Developer
[email protected]
[email protected]
ICQ#: 51055819
-
Nov 15th, 1999, 03:33 AM
#3
Thread Starter
Addicted Member
Thanks for the help!
but it seems that it only searches for one letter. I would need it to search incrementaly (as I type... Sorry I'm a french dude ) so that at the first letter I type, it searches for the nearest match and then for the second letter I type it searches for a new best match and so on...
what you posted only lets me write one letter and then if I type a second one, it overwrites the first letter.
any ideas?
-
Nov 15th, 1999, 04:26 AM
#4
Here's a Post I answered on the Same Question for another Member..
------------------
Aaron Young
Analyst Programmer
[email protected]
[email protected]
-
Nov 15th, 1999, 07:14 AM
#5
Thread Starter
Addicted Member
Thank you guys!!! you are the best!
Works great now!
-
Nov 15th, 1999, 07:30 AM
#6
Thread Starter
Addicted Member
Everything works great but I would like to make a Sub ot of the code so that I don't have to rewrite the code for each of my combo boxes.... Would you know why I get a GPF in module "User.exe" when I use this code?
Public Sub proTrouverDansCombo(ctl As Control, KeyCode As Integer)
Dim iIndex As Integer
Dim iStart As Integer
iStart = ctl.SelStart
iIndex = SendMessage(ctl.hwnd, CB_FINDSTRING, 0, ByVal ctl.Text)
If iIndex > -1 And KeyCode <> vbKeyDelete And KeyCode <> vbKeyBack Then
ctl = ctl.List(iIndex)
ctl.SelStart = iStart
ctl.SelLength = Len(ctl)
End If
End Sub
------------------------------
I call the Sub this way:
Private Sub dataClient_Appellatif_KeyUp(KeyCode As Integer, Shift As Integer)
Call proTrouverDansCombo(Me.ActiveControl, KeyCode)
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|