Home > Backend Development > C#.Net Tutorial > Detailed explanation of the automatic prompt, automatic completion and automatic completion functions of the TextBox input box in c# (pictures and text)

Detailed explanation of the automatic prompt, automatic completion and automatic completion functions of the TextBox input box in c# (pictures and text)

黄舟
Release: 2017-03-11 13:25:31
Original
4659 people have browsed it


Feature Overview


Detailed explanation of the automatic prompt, automatic completion and automatic completion functions of the TextBox input box in c# (pictures and text)

Detailed explanation of the automatic prompt, automatic completion and automatic completion functions of the TextBox input box in c# (pictures and text)

Detailed explanation of the automatic prompt, automatic completion and automatic completion functions of the TextBox input box in c# (pictures and text)

## 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 autocomplete is applied to a TextBox.


Property value Type: System.Windows.Forms.AutoCompleteMode
One of the AutoCompleteMode values. These values ​​are shown below.
Append
Appends the remainder of the most likely candidate string to the existing characters and highlights the appended characters.
Suggest
Display the auxiliary drop-down list associated with the edit control. This drop-down list is populated with one or more suggested completion strings.
SuggestAppend
Append Suggest and Append options.
None
Disable autocomplete This is the default value.

TextBox.AutoCompleteSource property

Gets or sets a value that specifies the source of complete strings used for autocomplete.

Remarks


Use the AutoCompleteCustomSource, AutoCompleteMode, and AutoCompleteSource properties to create a TextBox that compares the entered prefix with the prefixes of all strings in the maintained source. Automatically complete input strings. This is useful for TextBox controls that frequently have URLs, addresses, file names, or commands entered into them.

Use of the AutoCompleteCustomSource property is optional, but the AutoCompleteSource property must be set to CustomSource to use AutoCompleteCustomSource.
The AutoCompleteMode and AutoCompleteSource properties must be used together.

Sample Code


The following code example demonstrates how to use a collection as an autocomplete custom source for a TextBox control.

This example will do the following:
Use the AutoCompleteSource property to enable the TextBox control to accept a custom source for its autocomplete behavior.
Use the AutoCompleteCustomSource property to set a custom list of values.
Use the AutoCompleteMode property to set how autocomplete candidates are 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;
        }
Copy after login

The above is the detailed content of Detailed explanation of the automatic prompt, automatic completion and automatic completion functions of the TextBox input box in c# (pictures and text). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template