0

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.

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by sandeepparekh9
0

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());
0

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;
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.