private void comboKeyPressed()
            cboAuthor.DroppedDown = true;

            object[] originalList = (object[])cboAuthor.Tag;
            if (originalList == null)
                // backup original list
                originalList = new object[cboAuthor.Items.Count];
                cboAuthor.Items.CopyTo(originalList, 0);
                cboAuthor.Tag = originalList;

            // prepare list of matching items
            string s = cboAuthor.Text.ToLower();
            IEnumerable<object> newList = originalList;
            if (s.Length > 0)
                newList = originalList.Where(item => item.ToString().ToLower().Contains(s));

            // clear list (loop through it, otherwise the cursor would move to the beginning of the textbox...)
            while (cboAuthor.Items.Count > 0)
              //  cboAuthor.Items.Remove(cboAuthor.SelectedIndex);

            // re-set list

i got error in cboAuthor.Items.RemoveAt(0) on key press data in combobox is binded by database

Edited 1 Year Ago by priyanka_12: more clear

One option, modify the datasource and refill the combobox. Specific details of other options will depend on the objects in the datasource.

Edited 1 Year Ago by tinstaafl

Are you trying to remove the items while iterting the collection? This will give you the runtime can probably create a temporary list and modify and then re-assign.

put it in an events. for example.

private void button1_Click(object sender, EventArgs e)
This article has been dead for over six months. Start a new discussion instead.