C# ComboBox自动完成功能的例子
DataTable dt = new DataTable(); dt.Columns.Add("Name"); dt.Columns.Add("VV"); dt.Rows.Add(new string[] { "王一", "x" }); dt.Rows.Add(new string[] { "赵一", "z" }); dt.Rows.Add(new string[] { "王二", "y" }); dt.Rows.Add(new string[] { "赵二", "w" }); this.comboBox1.DataSource = dt; this.comboBox1.DisplayMember = "Name"; this.comboBox1.ValueMember = "VV"; this.comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems; this.comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
上面的 AutoCompleteSource 是大家应该关注的一点,具体的值有9种选择,其中8种是可以研究一下的