Need proper solution:
- User types in ComboBox.
- For every letter typed a list of matching names returnes from internet.
- ComboBox drop down list gets filled with items and text in comboBox stays unaffected.
My code:
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());
}
The above code works but list doesnt get dropped down , text cursor gets weird and sometimes throws an error.