今发现一个博文挺有意思,实现的功能很有意思但方法却很简单,特此转过来,以备以后查阅。
先上原博文地址: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事件就可以了
时间: 2024-10-14 06:51:17