I got tired working on that part of code for 3 days and searching on the internet please I need help to know HOW TO use auto complete textbox1 and use its value to set the value of textbox2 and textbox3 below code

public class PopulateProduct
        {
            public string ProductDesc { get; set; }
            public decimal UnitPrice { get; set; }
        }

        Dictionary<string, PopulateProduct> dict = new Dictionary<string, PopulateProduct>();

        public void load()
        {
            string connstr = "user id=rawpic;password=admin";
            string cmdtxt = @"select PRODUCT_ID,DESCRIPTION,UNIT_PRICE 
                                  from products";

            AutoCompleteStringCollection autocom = new AutoCompleteStringCollection();
            TB_PRODUCT_ID.AutoCompleteMode = AutoCompleteMode.Suggest;
            TB_PRODUCT_ID.AutoCompleteSource = AutoCompleteSource.CustomSource;
            TB_PRODUCT_ID.AutoCompleteCustomSource = autocom;

            using (OracleConnection conn = new OracleConnection(connstr))
            using (OracleCommand cmd = new OracleCommand(cmdtxt, conn))
            {
                try
                {
                    conn.Open();
                    OracleDataReader dr = cmd.ExecuteReader();

                    while (dr.Read())
                    {
                        dict.Add((string)dr["PRODUCT_ID"],
                            new PopulateProduct()
                            {
                                ProductDesc = (string)dr["DESCRIPTION"],
                                UnitPrice = (decimal)dr["UNIT_PRICE"]
                            });
                        autocom.Add(dr["PRODUCT_ID"].ToString());
                    }

                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message,"",MessageBoxButtons.OK,MessageBoxIcon.Error);
                }
            }
        }

Now my problem on the textbox1 where suggestion form oracle database should appear no suggestion appears and no data are assigned to textbox2 and textbox3

        private void TB_PRODUCT_ID_TextChanged(object sender, EventArgs e)
        {
            if (dict.ContainsKey(TB_PRODUCT_ID.Text)) 
            {
                TB_PRODUCTS_DESC.Text = dict[TB_PRODUCT_ID.Text].ProductDesc;
                TB_UNIT_PRICE.Text = dict[TB_PRODUCT_ID.Text].UnitPrice.ToString();
            }
        }

Have you checked to see if there was any data available in your dictionary after your database query?

Also for the autocomplete read this article from msdn or this stackoverflow thread, which were google's top results when searching "c# autocomplete on textbox"

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.