C#之Textbox实现自动提示容、自动补齐内容

今发现一个博文挺有意思,实现的功能很有意思但方法却很简单,特此转过来,以备以后查阅。

先上原博文地址http://blog.csdn.net/testcs_dn/article/details/45293253

 

再上效果图:

 

具体的实现代码:

设置数据源:

 1 var source = new AutoCompleteStringCollection();
 2 source.AddRange(new string[] 
 3 {   "monday",
 4     "tuesday",
 5     "wednesday",
 6     "thursday",
 7     "friday",
 8     "saturday",
 9     "sunday" 
10 });

将数据源设置到textbox

1 textBox1.AutoCompleteCustomSource = source;
2 textBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
3 textBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;

 把这些代码都加载到窗体的Load事件就可以了

posted @ 2016-07-20 18:56  imstrive  阅读(5411)  评论(0编辑  收藏  举报