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事件就可以了
菜鸟一枚,但有一颗不断进取的心;
兴趣所至,相信自己终会成功!!!!!
加油,imstrive