Link to home
Start Free TrialLog in
Avatar of Dmitriy Galankin
Dmitriy Galankin

asked on

AutoComplete doen't work when datagridview created dinamicly

Hello.
1. I has created a datagridview with some textbox cells dinamicly
2. I'm trying to add autocomplete text to cell (it doen't work when datagridview created dinamicly)

private void dataGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
        {
            (e.Control as DataGridViewTextBoxEditingControl).TextChanged -= cell_TextChanged;
            (e.Control as DataGridViewTextBoxEditingControl).TextChanged += cell_TextChanged;
        }

        void cell_TextChanged(object sender, EventArgs e)
        {
            AutoCompleteStringCollection acCollection = new AutoCompleteStringCollection();
            acCollection.Add("1122");
            acCollection.Add("1133");
            acCollection.Add("1144");
            acCollection.Add("1222");
            acCollection.Add("1333");
            acCollection.Add("1444");

            TextBox tb = sender as TextBox;
            tb.AutoCompleteSource = AutoCompleteSource.CustomSource;
            tb.AutoCompleteCustomSource = acCollection;
            tb.AutoCompleteMode = AutoCompleteMode.Suggest;   
        }

Open in new window


Why autocomplete list does not showing?
I'm sorry for my bad english....
ASKER CERTIFIED SOLUTION
Avatar of it_saige
it_saige
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dmitriy Galankin
Dmitriy Galankin

ASKER

Dear Saige, Thank you.

Your collection is formed in OnEditingControlShowing event.
My collection will consist from Russian postal address data (it's very big data)

I need to form a collection in cell_TextChanged event.

So i can form this data and my autoCompleteStringCollection isn't empty, but panel with autocomplete list doesn't show...
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
The problem was solved