A detailed description of the textbox input box auto-prompt, auto-complete, auto-complement function in C # (graphic)

Source: Internet
Author: User





Feature 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 is applied to a TextBox.
Property Value
Type: System.Windows.Forms.AutoCompleteMode
One of the AutoCompleteMode values. These values are the following.
Append
Appends the remainder of the most likely candidate string to an existing character and highlights the appended character.
Suggest
Displays the secondary drop-down list associated with the edit control. This drop-down list fills in one or more suggested completion strings.
SuggestAppend
Append Suggest and Append options.
None
Disable Auto-completion This is the default value.



Textbox.autocompletesource Property



Gets or sets a value that specifies the source of the complete string that is used for auto-completion.



Note



Use the AutoCompleteCustomSource, AutoCompleteMode, and AutoCompleteSource properties to create a TextBox that It automatically completes the input string by comparing the prefix entered with the prefix of all the strings in the maintained source. This is useful for TextBox controls that frequently have URL, address, file name, or command input.
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 custom sources that are auto-completed as a TextBox control.
This example performs the following actions:
Use the AutoCompleteSource property to enable a 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 candidates are displayed automatically.


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;
        }
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.