3

I have a textbox in my C# Windows Forms application that has AutoCompleteMode set to AutoCompleteMode.Suggest, and my content source is a custom source.

My content source is custom, with the following values:

  • Jim Smith
  • Alice Walker
  • Bob Walker
  • Jeremy Smith

The content completion only appears to work by checking if the suggested items "start with" the value in the textbox.

For example:

text=J

Would result in the suggestions:

  • Jim Smith
  • Jeremy Smith

However, if the user types in

text=Walk

There are no results.

How can I get content completion to suggest the following?

  • Alice Walker
  • Bob Walker

Also, my end goal is to have a textbox where individuals can easy start typing email addresses. The content of the autocompletion suggestions will be names + email addresses. For example:

- Jim Smith <jsmith@mycorp.com>
- Alice Walker <alice@some.email.com>
- Bob Walker <bob.walker@mycorp.com>
- Jeremy Smith <jeremys@foo.com>
juharr
  • 31,741
  • 4
  • 58
  • 93
GreenKiwi
  • 1,025
  • 13
  • 28
  • @juharr thanks for fixing that, missed that in the preview. – GreenKiwi Nov 17 '14 at 19:14
  • 1
    Check out [A more useful auto-complete Textbox control](http://www.emoreau.com/Entries/Articles/2012/04/A-more-useful-auto-complete-Textbox-control.aspx) – C-Pound Guru Nov 17 '14 at 19:20
  • 1
    See answer to this one (same question): http://stackoverflow.com/questions/1437002/winforms-c-sharp-autocomplete-in-the-middle-of-a-textbox – loopedcode Nov 17 '14 at 19:23
  • Marked this as a dup of the question above, so others go directly to that question. (But I can't actually close it as a duplicate.) – GreenKiwi Nov 18 '14 at 19:49

1 Answers1

3

This is not possible with the built-in TextBox.

Reading the reference source reveals that the AutoComplete feature calls into the native function SHAutoComplete to do it's job. That one does only prefix matching.

You would have to subclass TextBox and provide your own suggestion feature (or purchase one / find an open source one), to do this.

driis
  • 161,458
  • 45
  • 265
  • 341