Re: Autocomplete in combobox
here is one written by some horrible coder named kleinma...
(even though it says Anonymous... thanks to plenderj :( )
http://www.freevbcode.com/ShowCode.Asp?ID=7007
it does autocomplete, but does not display the items below the combobox, like IE does...
Re: Autocomplete in combobox
alright, great thanks!! I'll have a look. I don't understand how come that things so widely use in windows applications aren't already implemented in vb.
Thanks lots!
Re: Autocomplete in combobox
if you want to implement the AutoComplete that InternetExplorer uses ( eg: retrieve the web pages visited etc... ) you need to find the EDIT window of your ComboBox , then you can set the SHAutoComplete on it , eg:
VB Code:
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWnd1 As IntPtr, ByVal hWnd2 As Int32, ByVal lpsz1 As String, ByVal lpsz2 As String) As IntPtr
Private Declare Sub SHAutoComplete Lib "shlwapi.dll" (ByVal hwndEdit As IntPtr, ByVal dwFlags As Int32)
Private Const SHACF_AUTOAPPEND_FORCE_ON As Int32 = &H40000000
Private Const SHACF_AUTOSUGGEST_FORCE_ON As Int32 = &H10000000
Private Const SHACF_URLHISTORY As Int32 = &H2
Private Const SHACF_URLMRU As Int32 = &H4
Private Const SHACF_URLALL As Int32 = (SHACF_URLHISTORY Or SHACF_URLMRU)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'/// first you need to find the EDIT part of the ComboBox
Dim ptr As IntPtr = FindWindowEx(ComboBox1.Handle, 0, "EDIT", Nothing)
If Not ptr.Equals(IntPtr.Zero) Then '/// it's found it.
SHAutoComplete(ptr, SHACF_AUTOAPPEND_FORCE_ON Or SHACF_AUTOSUGGEST_FORCE_ON Or SHACF_URLALL)
End If
End Sub
hope it helps :wave: