ComboBox中输入文字匹配自动检索匹配数据 在线等!c#
意思是:假如我的ComboBox的list中有abcd, abde, acdf等等项目。如果我开始输入a,combobox应当立即显示abcd,并且,bcd是选中状态,以便用户继续输入。如果第二个输入c,则马上显示acdf,并且df是选中状态。我说的combobox是dropdown样式的。
[解决办法]
this.comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend; this.comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;
[解决办法]
this.comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
this.comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;
[解决办法]
private void comboBox1_TextChanged(object sender, EventArgs e) { string str = this.comboBox1.Text; for (int i = 0; i < this.comboBox1.Items.Count; i++) { if (this.comboBox1.Items[i].ToString().IndexOf(str) == 0) { this.comboBox1.Text = this.comboBox1.Items[i].ToString(); this.comboBox1.Select(str.Length, this.comboBox1.Text.Length - str.Length); break; } } }
[解决办法]