The winform control automatically prompts you to define similar item values.

Source: Internet
Author: User
In many cases, winform also needs to be like webform. When entering some content, it will automatically display more or similar content. Baidu and Google use this method.
This makes it easier for many users to use the system you designed. In the winform design, you only need to use their autocompletemode and autocompletesource.
Method. The following is an example:
First, create a project, pull a textbox on form1, and enter it with the ComboBox control. Code Interface, write the following code in the form1_load event: Private   Void Form1_load ( Object Sender, eventargs E)
{
Textbox1.autocompletecustomsource. addrange ( New   String [] { " James " , " Kobe " , " T-MC " , " Jameslee " , " King " , " TOT " });
Textbox1.autocompletemode = Autocompletemode. suggestappend;
Textbox1.autocompletesource = Autocompletesource. customsource;

Combobox1.items. addrange ( New   String [] { " James " , " Kobe " , " T-MC " , " Jamesli " , " King " , " TT " });
Combobox1.autocompletecustomsource. addrange ( New   String [] { " James " , " Kobe " , " T-MC " , " Jameslee " , " King " , " TOT " });
Combobox1.autocompletemode = Autocompletemode. Suggest;
Combobox1.autocompletesource = Autocompletesource. customsource;
}

Note: autocompletemode has four attributes: append, none, suggest, and suggestappend:
Append is to append the first similar item to the end of your input character.
None means no prompt
Suggest displays similar items in the list
Suggestappend is to add the first similar item to the end of your input character and display all similar items in the list below.

Autocompletecustomsource is optional, but you must set the autocompletesource attribute to customsource before using autocompletecustomsource.
The autocompletemode and autocompletesource attributes must be used together.

The running result of the above Code is as follows:

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.