views:

568

answers:

4

Hi, 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" ([email protected])
"Bob Johnson" ([email protected])
"Willy Johnston" ([email protected])
"Willy Williams" ([email protected])

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

+1  A: 

Have you looked into the Ajax Control Toolkit?

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

Mike
+3  A: 

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
Question clarified as to expected behavior. The .NET 2.0 controls would not satisfy this criteria.
greg7gkb
A: 

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
+1  A: 

Hi all,

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.

Thanks,

-Greg

greg7gkb