Dynamically changing Textbox’s AutoComplete List causes AccessViolationException, any advice?

It’s Possible!!!
About 3 hours searching and according to information in this post I found solution.
You have to delete almost all elements from AutoCompleteCustomSource (or ComboBox.Items), Then AddRange() and finaly remove 0-index item:

private void comboBox1_PreviewKeyDown(...) {
        while (comboBox1.Items.Count > 1) {
                 comboBox1.Items.RemoveAt(comboBox1.Items.Count - 1);
        }
        comboBox1.Items.AddRange(<your_new_items>);
        comboBox1.Items.RemoveAt(0);
}

But this method too slow (in autocomplete time), maybe Cause you have to remove elements one-by-one.
Sorry for my English.

Leave a Comment