Features Overview
related Properties Textbox.autocompletecustomsource Property
Gets or sets the custom t:system.collections.specialized.stringcollection to use when the Textbox.autocompletesource property is set to [CustomSource]. Textbox.autocompletemode Property
Gets or sets an option that controls how automatic completion applies to the TextBox.
Property Value
Type: System.Windows.Forms.AutoCompleteMode
One of the AutoCompleteMode values. The following are the values.
Append
Appends the remainder of the most likely candidate string to an existing character and highlights the appended characters.
Suggest
Displays the secondary Drop-down list associated with the edit control. This drop-down list populates one or more of the recommended completion strings.
SuggestAppend
Append suggest and Append options.
None
Disable automatic completion This is the default value. Textbox.autocompletesource Property
Gets or sets a value that specifies the source of the complete string used for automatic completion. Notes
You can create a TextBox by using the AutoCompleteCustomSource, AutoCompleteMode, and AutoCompleteSource properties. It automatically completes the input string by comparing the prefix entered with the prefix of all the strings in the source being maintained. This is useful for a TextBox control that frequently has a URL, address, file name, or command entry.
The use of the AutoCompleteCustomSource property is optional, but you must set the AutoCompleteSource property to CustomSource before you can use AutoCompleteCustomSource.
The AutoCompleteMode and AutoCompleteSource properties must be used together. Sample Code
The following code example demonstrates how to use a collection of AutoComplete custom sources as a TextBox control.
This example performs the following actions:
Use the AutoCompleteSource property to enable the TextBox control to accept custom sources for its AutoComplete behavior.
Use the AutoCompleteCustomSource property to set a custom list of values.
Use the AutoCompleteMode property to set how candidates are automatically displayed.
private void Form1_Load (object sender, EventArgs e)
{
var source = new AutoCompleteStringCollection ();
Source. AddRange (new string[]
{
"January",
"February",
"March",
"April",
"may",
"June",
"July",
"August", "
September",
"October",
"November",
"December"
});
textBox1.AutoCompleteCustomSource = source;
Textbox1.autocompletemode = AutoCompleteMode.SuggestAppend;
Textbox1.autocompletesource = Autocompletesource.customsource;
}
Source Download
C#textbox input box automatic prompt, automatic completion, automatic complement full function