Results 1 to 4 of 4

Thread: Autocomplete in combobox

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2004
    Posts
    70

    Resolved Autocomplete in combobox

    Hi, I'm trying to make the same thing the addres text box of the internet explorer does. This is while you type it shows you what entries are like the one you are typing.

    Any ideas? Somebody said something about using autocomplete... but haven't seen anything related to a combobox called autocomplete.

    Thanks, folks!
    Last edited by nacho2; Dec 27th, 2004 at 04:25 PM.

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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...

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2004
    Posts
    70

    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!

  4. #4
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142

    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:
    1. 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
    2.     Private Declare Sub SHAutoComplete Lib "shlwapi.dll" (ByVal hwndEdit As IntPtr, ByVal dwFlags As Int32)
    3.     Private Const SHACF_AUTOAPPEND_FORCE_ON As Int32 = &H40000000
    4.     Private Const SHACF_AUTOSUGGEST_FORCE_ON As Int32 = &H10000000
    5.     Private Const SHACF_URLHISTORY As Int32 = &H2
    6.     Private Const SHACF_URLMRU As Int32 = &H4
    7.     Private Const SHACF_URLALL As Int32 = (SHACF_URLHISTORY Or SHACF_URLMRU)
    8.  
    9.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    10.         '/// first you need to find the EDIT part of the ComboBox
    11.         Dim ptr As IntPtr = FindWindowEx(ComboBox1.Handle, 0, "EDIT", Nothing)
    12.         If Not ptr.Equals(IntPtr.Zero) Then '/// it's found it.
    13.             SHAutoComplete(ptr, SHACF_AUTOAPPEND_FORCE_ON Or SHACF_AUTOSUGGEST_FORCE_ON Or SHACF_URLALL)
    14.         End If
    15.     End Sub
    hope it helps
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width