需要适当的解决方案:
我的代码:
private void InitializeComboBoxSearchSymbol()
{
comboBoxSearchName.ValueMember = "first_name";
comboBoxSearchName.DisplayMember = "first_name";
comboBoxSearchName.AutoCompleteMode = AutoCompleteMode.None;
comboBoxSearchName.SelectedIndexChanged += comboBoxSearchName_SelectedIndexChanged;
comboBoxSearchName.KeyDown += SearchNameTextChanged;
}
private void comboBoxSearchName_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void SearchNameTextChanged(object sender, KeyEventArgs e)
{
YahooData yd = new YahooData();
List<Name> listNames = yd.YahooNameLookup(comboBoxSearchName.Text);
comboBoxSearchName.Items.Clear();
comboBoxSearchName.Items.AddRange(listNames.ToArray());
}
上面的代码有效,但是列表没有被删除,文本光标变得怪异,有时会抛出错误。
答案 0 :(得分:0)
以编程方式打开Win Forms组合框:
comboBoxSearchName.DroppedDown = true;