autocomplete textbox / combobox and gridview

0

I give up, I have not found an answer, I am a beginner in C # and I have a class where every weekend the teacher leaves us a challenge-type task, and this time it was a search engine, but using the data generated via a code. single column of the gridview (the data was already, I just have to write the search engine code) and it is assumed that what must happen is that you write a letter in the textbox and it displays the words that begin with that letter within the gridview. After a long search I found the following code that I do not even know if it is the correct one, the internet is not much use because the tutorials are based on SQL

string[] productListSearch = new string[InventoryTable.Rows.Count];


        for (int unitP = 0; unitP < InventoryTable.Rows.Count; unitP++)
        {
            productListSearch[unitP] = Convert.ToString(InventoryTable.Rows[unitP].Cells[0].Value);
        }
        InventorySearch.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
        InventorySearch.AutoCompleteSource = AutoCompleteSource.CustomSource;

        InventorySearch.AutoCompleteCustomSource.AddRange(productListSearch);
    
asked by meme 20.05.2017 в 02:22
source

1 answer

0

Here is resolved

private void Form1_Load(object sender, EventArgs e)
    {

        string[] productListSearch = new string[dataGridView1.Rows.Count];
        for (int unitP = 0; unitP < dataGridView1.Rows.Count; unitP++)
        {
            productListSearch[unitP] = Convert.ToString(dataGridView1.Rows[unitP].Cells[0].Value);
        }
        var fuente = new AutoCompleteStringCollection();
        fuente.AddRange(productListSearch);
        comboBox1.AutoCompleteCustomSource = fuente;
        comboBox1.AutoCompleteMode = AutoCompleteMode.Suggest;
        comboBox1.AutoCompleteSource = AutoCompleteSource.CustomSource;
    }
    
answered by 20.05.2017 в 23:31