C#中TextBox实现输入提示功能的方法
程序员文章站
2024-02-06 11:31:34
本文实例讲述了c#中textbox实现输入提示功能的方法。分享给大家供大家参考。具体如下:
设置textbox的autocompletesource的属性为customs...
本文实例讲述了c#中textbox实现输入提示功能的方法。分享给大家供大家参考。具体如下:
设置textbox的autocompletesource的属性为customsource,设置textbox的autocompletemode属性为suggestappend。
using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.text; using system.windows.forms; using windowsapplication7.dataset1tableadapters; namespace windowsapplication7 { public partial class form1 : form { dataset1 ds = new dataset1(); customerstableadapter adpter = new customerstableadapter(); public form1() { initializecomponent(); } private void buildautocompletelist() { autocompletestringcollection filtervals = new autocompletestringcollection(); foreach (datarow dr in ds.customers) { filtervals.add(dr["companyname"].tostring()); } txtcompanyname.autocompletecustomsource = filtervals; } private void form1_load(object sender, eventargs e) { adpter.fill(ds.customers); buildautocompletelist(); } } }
希望本文所述对大家的c#程序设计有所帮助。