我有一个ComboBox,代码如下:
private void comboBox1_TextChanged(object sender, EventArgs e)
{
using (var service = WebServiceHelper.GetCoreService())
{
string physicianXml = service.SearchPhysicians(SessionInfo.Current.ClientCode, SessionInfo.Current.MachineName,
SessionInfo.Current.Username, comboBox1.Text);
var physicians = PhysicianItemList.FromXml(physicianXml);
AutoCompleteStringCollection autoCompleteStringCollection = new AutoCompleteStringCollection();
foreach (var physician in physicians.Items)
{
autoCompleteStringCollection.Add(physician.LastName + ", " + physician.FirstName);
}
comboBox1.AutoCompleteCustomSource = autoCompleteStringCollection;
comboBox1.Select(comboBox1.Text.Length, 0);
}
}
基本上,用户输入医生姓名的前几个字符,应该会自动填充匹配度最高的前100条记录。虽然它很好用,但我需要将其关联到一个键(可以是表中的PK或医师的NPI编号)。看来
AutoCompleteStringCollection
不支持键。有人能建议一种方法吗?表中大约有700万条记录,所以我不想预先填充ComboBox。谢谢。