2

I'm looking for a solution like the one discussed here, but for C# WinForms. Link here

To rephrase, is it possible to do textbox autocompletes in C# using a single data source with multiple lines? Result should be like Gmail's TO: field in creating emails, or similarly MS Outlook's TO: field.

For example, the data set might be:
"John Williams" (john.williams@gmail.com)
"Bob Johnson" (john.jacobs@gmail.com)
"Willy Johnston" (willy.williams@gmail.com)
"Willy Williams" (johnjohn@gmail.com)

... and I should be able to type "john" and all four would be suggested. If I typed "johns" then the second and third entries would be suggested.

This is more advanced than the auto-complete provided by .NET by default.

Thanks, -Greg

Community
  • 1
  • 1
greg7gkb
  • 4,933
  • 4
  • 41
  • 55

4 Answers4

3

The WinForms 2.0 controls already provide this functionality in the AutoCompleteSource property. You can set this to a datasource or build your own list of strings with AutoCompleteStringCollection.

Dour High Arch
  • 21,513
  • 29
  • 75
  • 90
3

I ended up writing my own UserControl custom class to take care of this. It didn't appear there was anything out there that met my needs.

I've provided the source and DLL here under BSD: http://code.google.com/p/email-autocomplete

Basically, it emulates the functionality of the "To:" box on Gmail but of course in .NET.

greg7gkb
  • 4,933
  • 4
  • 41
  • 55
1

Have you looked into the Ajax Control Toolkit?

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx

Mike
  • 5,437
  • 7
  • 45
  • 62
0

In control (for example TextBox) Properties tab, open Behavior section and set AutoCompleteType to needed value. You can do the same programatically. For your control (for example TextBox TextBox1) call AutoCompleteType type and initialize value (for example TextBox1.AutoCompleteType = AutoCompleteType.Email; )

Davit Siradeghyan
  • 6,053
  • 6
  • 24
  • 29