Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Auto-Completion Edit Control

0.00/5 (No votes)
16 Jul 2001 1  
An edit control that provides auto-completion functionality for small data sets.
  • Download demo project - 19 Kb
  • Download source - 4 Kb

    This article describes a class (CACEditCtrl) for an Auto-Completion Edit Control, which can be used small data sets, such as most-recently-used account numbers, etc.

    It works by iterating over a collection of STL strings and tries to find a matching beginning-substring in the entry. It is not the most the most effecient way of doing it, but it works well for small data sets.

    The two functions of interest are:

    • void AddACEntry( LPCTSTR cpEntry )
    • void DisableAC( bool bDisable = true )

    The AddACEntry(...) function is used to add a string to the control's collection of strings. No duplicate checking is done. Why? Because this control acts as a container for data, not a manager of data.

    The DisableAC(...) function allows you to turn the Auto-Completion feature on or off.

    In the demo image above, the numbered dialogs show the operation of the control as 3 characters are typed into it :"T", "h", and "a" as shown below:

    1. No characters typed
    2. A "T" was typed into the control, and it auto-completed with its first match
    3. A "h" was typed into the control, ditto above
    4. An "a" was typed into the control, and there were no matches to auto-complete for

    Conditions of use are detailed in the header and source file(s).

    Feel free to contact me if there are any questions. Have fun.

  • License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here