Go to my github

C# WinForm 技巧四:COMBOBOX搜索提示

comboBox和textBox支持内置的搜索提示功能,

   在form的InitializeComponent()中添加如下语句:
   this.comboBox1.AutoCompleteCustomSource.AddRange(new string[] { "10.152.154.89", "10.152.154.90", "10.152.252.10", "10.152.252.11" });//是将数据添加到搜索范围

//默认是None,还有Append,和SuggestAppend属性,除了默认的None都可以实现搜索提示的功能
this.comboBox1.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
this.comboBox1.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.CustomSource;

posted @ 2010-03-17 15:31  峡谷少爷  阅读(2149)  评论(0编辑  收藏  举报