greg7gkb
greg7gkb

Reputation: 5040

Autocomplete email address and/or names in C#

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

Upvotes: 2

Views: 3925

Answers (4)

greg7gkb
greg7gkb

Reputation: 5040

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.

Upvotes: 3

Davit Siradeghyan
Davit Siradeghyan

Reputation: 6323

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; )

Upvotes: 0

Dour High Arch
Dour High Arch

Reputation: 21712

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.

Upvotes: 3

Mike
Mike

Reputation: 5509

Have you looked into the Ajax Control Toolkit?

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

Upvotes: 1

Related Questions