Comma or semicolon-delimited AutoComplete TextBox

Posted by Ecyrb on Stack Overflow See other posts from Stack Overflow or by Ecyrb
Published on 2010-02-18T17:50:06Z Indexed on 2010/03/29 22:13 UTC
Read the original article Hit count: 366

Filed under:
|
|
|
|

I would like to have a TextBox that supports AutoComplete and lets users type multiple words separated by a comma or semicolon, offering suggestions for each word. I have a standard TextBox with

textBox.AutoCompleteCustomSource.AddRange(new[] { "apple", "banana", "carrot" });
textBox.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
textBox.AutoCompleteSource = AutoCompleteSource.CustomSource;

Unfortunately it will only suggest for the first word. Anything typed after that and it stops suggesting.

I want to be able to perform the following scenario:

  1. Type "ap"
  2. Have it suggest "apple"
  3. Press the comma
  4. Have it fill in "apple," with the cursor after the comma
  5. Type "ba"
  6. Have it suggest "banana"
  7. Press the comma
  8. Have it append "banana," resulting in "apple,banana,"

I've tried Googling for a solution, but haven't had much luck. This seems to be a popular feature for web apps, but apparently not for winforms. Any suggestions?

© Stack Overflow or respective owner

Related posts about winforms

Related posts about c#