textbox 输入值提示。。。(类似百度搜索)
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
public void textBox5_xiala() { DataSet ds = SQl_yuji.ds_cinvname(); this.textBox5.AutoCompleteMode = AutoCompleteMode.SuggestAppend; this.textBox5.AutoCompleteSource = AutoCompleteSource.CustomSource; // DataTable table = new DataTable(); // table = ds.Tables[0]; ArrayList al = new ArrayList(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (!al.Contains(ds.Tables[0].Rows[i]["cInvName"].ToString())) { al.Add(ds.Tables[0].Rows[i]["cInvName"].ToString()); } } AutoCompleteStringCollection ac = new AutoCompleteStringCollection(); string[] s = (string[])al.ToArray(typeof(string)); for (int i = 0; i < s.GetLength(0); i++) { ac.Add(s[i]); } this.textBox5.AutoCompleteCustomSource = ac;//设置该文本框的自动完成数据源 }
效果图