In Winform, The TextBox Control Enables automatic prompt filling function, winformtextbox

Source: Internet
Author: User

In Winform, The TextBox Control Enables automatic prompt filling function, winformtextbox

Problem:In Winform development, a TextBox Control is used to enter a name. You want to automatically prompt all possible names when entering a name.

 

Answer:The TextBox Control in winform contains the following three attributes:

Automated completion ① AutoCompleteMode: Automatic prompt and completion method. For more information, see AutoCompleteMode enumeration;

Optional bytes ② AutoCompleteSource: the string source used for automatic prompt and completion. For specific settings, see AutoCompleteSource. When setting the value to CustomSource, you must set the ③ attribute;

Optional parameter ③ AutoCompleteCustomSource: Custom automatic prompts and complete the string source used.

Just set the above three attributes to solve the problem.

This. textBox1.AutoCompleteMode = AutoCompleteMode. suggestAppend; this. textBox1.AutoCompleteSource = AutoCompleteSource. customSource; string [] names = new string [] {"Zhang Sanfeng", "dedicated for defeat", "Feng Qingyang", "sweeping the floor"}; this. textBox1.AutoCompleteCustomSource. addRange (names );

  

The preceding operations are also applicable to the ComboBox control.

  Thoughts:If ComboBox uses its Items attribute (that is, the drop-down list) as the string source, how do I set it?

  ParameterExam:

String [] names = new string [] {"Zhang Sanfeng", "dedicated for defeat", "Feng Qingyang", "sweeping the floor"}; this. comboBox1.Items. addRange (names); this. comboBox1.AutoCompleteMode = AutoCompleteMode. suggestAppend; this. comboBox1.AutoCompleteSource = AutoCompleteSource. listItems;

  

Article synchronous update: http://www.motyer.cn/Files/BlogDetails/winform-textbox-autocomplete.html

 

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.