0
votes

Need proper solution:

  1. User types in ComboBox.
  2. For every letter typed a list of matching names returnes from internet.
  3. 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.

1

1 Answers

0
votes

To open a Win Forms combobox programmatically:

comboBoxSearchName.DroppedDown = true;