Visual studio 2005 and access 2007.
Autocomplte textbox is not displaying results.
Here is my code

txtname.AutoCompleteCustomSource = m_namesCollection;
                m_namesCollection.Clear();

                if (!String.IsNullOrEmpty(txtname.Text.Trim().ToString()))
                {
                    m_search = txtname.Text.Trim().ToString();
                    foreach (DataRow cust_dr_autoloop in m_dt_Customer.Rows)
                    {
                        if (cust_dr_autoloop["cust_name"].ToString().StartsWith(m_search))
                        {
                            m_namesCollection.Add(cust_dr_autoloop["cust_name"].ToString());
                        }
                    }
                }

I have set the autocomplete mode to suggest and autocomplete source to custom source.

I have written the above code in the text change event.
I also added the following line of code to ensure some results are returned.

MessageBox.Show(m_namesCollection.Count.ToString());

i dont think u need to manually right all this..

just type this code on form load event or any other that may see

foreach (DataRow cust_dr_autoloop in m_dt_Customer.Rows)
                    {                       if (cust_dr_autoloop["cust_name"].ToString().StartsWith(m_search))
                        {
                            m_namesCollection.Add(cust_dr_autoloop["cust_name"].ToString());
                        }
                    }

now u will have all the cust_name collection in m_namesCollection .. the assign this collection to text box autocomlete

like this:

txtname.AutoCompleteCustomSource = m_namesCollection;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.