I'm looking for a solution like the one discussed here, b开发者_如何学Gout 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
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.
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.
Have you looked into the Ajax Control Toolkit?
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/AutoComplete/AutoComplete.aspx
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; )
精彩评论