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.RemoveAt(0);
// cboAuthor.Items.Remove(cboAuthor.SelectedIndex);
}
// re-set list
cboAuthor.Items.AddRange(newList.ToArray());
}
i got error in cboAuthor.Items.RemoveAt(0) on key press data in combobox is binded by database