C # automatic prompt, Automatic completion, and automatic completion in the TextBox input box,

Source: Internet
Author: User

C # automatic prompt, Automatic completion, and automatic completion in the TextBox input box,
Function Overview

Related attributes TextBox. AutoCompleteCustomSource attributes

Gets or sets the custom T: System. Collections. Specialized. StringCollection to be used when the TextBox. AutoCompleteSource attribute is set to [CustomSource.

TextBox. AutoCompleteMode attribute

Gets or sets an option, which controls the method that is automatically applied to TextBox.
Attribute Value
Type: System. Windows. Forms. AutoCompleteMode
One of the AutoCompleteMode values. These values are as follows.
Append
Append the rest of the most likely candidate string to an existing character and highlight the appended character.
Suggest
Displays the secondary drop-down list associated with the editing control. This drop-down list is filled with one or more recommended completion strings.
SuggestAppend
Append the Suggest and Append options.
None
Automatic completion is disabled. This is the default value.

TextBox. AutoCompleteSource attributes

Gets or sets a value that specifies the source of the complete string that is automatically completed.

Remarks

You can use the AutoCompleteCustomSource, AutoCompleteMode, and AutoCompleteSource attributes to create a TextBox. It automatically completes the input string by comparing the entered prefix with the prefix of all strings in the maintained source. This is useful for TextBox controls that frequently contain URLs, addresses, file names, or command input.
AutoCompleteCustomSource is optional, but you must set the AutoCompleteSource attribute to CustomSource before using AutoCompleteCustomSource.
The AutoCompleteMode and AutoCompleteSource attributes must be used together.

Sample Code

The following code example demonstrates how to use a set as a TextBox Control to automatically complete a custom source.
In this example, the following operations are performed:
Use the AutoCompleteSource attribute to enable the TextBox Control to accept custom sources for its Automatic completion behaviors.
Use the AutoCompleteCustomSource attribute to set the custom list of values.
Use the AutoCompleteMode attribute to set the Automatic Display Mode of the candidate.

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 code download

C # automatic prompt, Automatic completion, and automatic completion in textbox input box

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.