steve potts

steve potts

  • NA
  • 29
  • 10.4k

autocompletecustomsource c#

Nov 21 2012 10:01 AM
Hi all, Currently I have a combobox that is all working and i can search it by typing in order from the start, but if i wanted to search later in the string, for example, lastname instead of typing the firstname first, it will not search the box, i believe its something to do with needing a customautocomplete source, but i cant get that to work with my code..
any help?

// On form load, connect to DB and get the contact list
            string MyConString = "SERVER=192.168.0.89;" +
                "DATABASE=sms;" +
                "UID=user;" +
                "PASSWORD=password;";
            
            MySqlConnection connection = new MySqlConnection(MyConString);
            
            string command = "select name,number from pbk";
            
            MySqlDataAdapter da = new MySqlDataAdapter(command, connection);
            
            DataTable dt = new DataTable();
            
            da.Fill(dt);

            // Fill the contact list dropdown

            foreach (DataRow row in dt.Rows)
            {
                string rows = string.Format("{0}:{1}", row.ItemArray[0], row.ItemArray[1]);
                
                comboBox1.Items.Add(rows);
            }
            connection.Close();