参考这个:
DataTable tb = new DataTable();
tb.Columns.Add(new DataColumn("id", typeof(int)));
tb.Columns.Add(new DataColumn("name", typeof(string)));
for (int i = 0; i < 10; i++)
{
DataRow dr = tb.NewRow();
dr["id"] = i;
dr["name"] = "a" + i.ToString();
tb.Rows.Add(dr);
}
comboBox1.DataSource = tb;
comboBox1.DisplayMember = "name";
comboBox1.ValueMember = "id";
comboBox1.AutoCompleteSource = AutoCompleteSource.ListItems;
comboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
1.数据源绑定是否成功
2.autocompletemode设置为suggestAppend
3.autocompletesource设置为listitems
用textbox和listbox自己做一个