First, please download the source code from the Code Project, which contains a large number of API calls, as well as detailed descriptions and examples, and you can generate ShellLib.dll directly in your own program.
The source code describes how to use the ShautoComplete API and demonstrate how to add custom StringTable for ComboBox, but not explain how to define for Textbox. In fact, this function can be achieved by a little revision.
The following code illustrates the above problems:
Public static void autocomplete (system.windows.forms.textbox textbox, string [] list)
{
// Define and instantiate the shelLautocomplete object
Shellautocomplete ac = new shellautocomplete ();
// Bind the TextBox object
Ac.EDithandle = textbox.handle;
// Set the auto-complete option
Ac.acoptions = shellautocomplete.AutocompleteOptions.none;
Ac.acoptions | = shellautocomplete.autocompleteOptions.autosuggest;
Ac.acoptions | = shellautocomplete.autocumbpend;
Ac.acoptions | = shellautocomplete.autocompleteOptions.UpdownKeyDropslist;
Ac.acoptions | = shellautocomplete.AutocompleteOptions.usetab;
// Define and return a list to display
SourceCustomlist Custom = New SourceCustomlist ();
Custom.StringList = List;
ac.Listsource = Custom;
/ / Try to activate Automatic completion
Try
{
/ / Activate automatic completion function
ac.setautocomplete (true);
}
Catch
{
// If an error is wrong?
Return;
}
}