手机
当前位置:查字典教程网 >编程开发 >C#教程 >C#中TextBox实现输入提示功能的方法
C#中TextBox实现输入提示功能的方法
摘要:本文实例讲述了C#中TextBox实现输入提示功能的方法。分享给大家供大家参考。具体如下:设置TextBox的AutoCompleteSou...

本文实例讲述了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#程序设计有所帮助。

【C#中TextBox实现输入提示功能的方法】相关文章:

c#实现隐藏与显示任务栏的方法详解

C#实现图片分割方法与代码

C#中实现网段扫描的代码

c#之利用API函数实现动画窗体的方法详解

C#定位txt指定行的方法小例子

C# 语音功能的实现方法

C# 鼠标穿透窗体功能的实现方法

C#用Activex实现Web客户端读取RFID功能的代码

C#.NET字符串比较中忽略符号的方法

C#保存图片到数据库并读取显示图片的方法

精品推荐
分类导航