Skip to content

Autocomplete textbox in Mdi child form c#

sayeed BAGBAN

Asked Oct 9, 2013, 3:21 AM EDT2 answers
Share
LinkedInX
Hi everyone,

Can any one please let me know how the Auto complete works in Mdi child form ?

I have created the simple windows from in that the below code is working fine but the same code if i implement it to MDI Child form then the same suggestion is not working?

using (OleDbConnection con = new OleDbConnection(ConString))
                {
                    OleDbCommand cmd = new OleDbCommand("Select ConsigneeName From tblConsignee", con);
                    OleDbDataReader dReader;
                    SqlConnection conn = new SqlConnection();
                    con.ConnectionString = ConString;
                    con.Open();
                    dReader = cmd.ExecuteReader();

                    if (dReader.HasRows == true)
                    {
                        while (dReader.Read())
                            namesCollection.Add(dReader["ConsigneeName"].ToString());
                    }
                    else
                    {

                    }
                    dReader.Close();
                    txtConsigneeName.AutoCompleteCustomSource = namesCollection;
                    txtConsigneeName.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                    txtConsigneeName.AutoCompleteSource = AutoCompleteSource.CustomSource;
                }

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • Sunny  Sharma
    0
    Keep the code in a separate class and call the methods from any form on textchanged event of textbox, it will do.
    0
  • 0
    Hi,

    I have attached the code for what the process you had replied to me but still it doesnt show the Autocomplete.
    0