今发现一个博文挺有意思,实现的功能很有意思但方法却很简单,特此转过来,以备以后查阅。
先上原博文地址:http://blog.csdn.net/testcs_dn/article/details/45293253
再上效果图:
具体的实现代码:
设置数据源:
var source = new AutoCompleteStringCollection();
source.AddRange(new string[]
{ "monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday"
});
将数据源设置到textbox
textBox1.AutoCompleteCustomSource = source;
textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
把这些代码都加载到窗体的Load事件就可以了