//creat auto complete Collection
AutoCompleteStringCollection collection = new AutoCompleteStringCollection();
//Connection String
string connectionString = "Data Source=5555.55555.5555555;Initial Catalog=DB;Persist Security Info=True;User ID=id;Password=password";
//creating connection String
SqlConnection con = new SqlConnection(connectionString);
//open the connection
con.Open();
//get the data from database
SqlDataAdapter ad = new SqlDataAdapter("select CUSTOMER_NAME from MT_FLST_QT_QUOTATION", con);
DataTable dt = new DataTable();
ad.Fill(dt);
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
//add the student name into auto complete collection
collection.Add(dt.Rows[i].ItemArray[0].ToString());
}
}
//after adding the student names into auto complete collection bind the collection to textbox
txt_customer_name.AutoCompleteMode = AutoCompleteMode.Suggest;
txt_customer_name.AutoCompleteSource = AutoCompleteSource.CustomSource;
txt_customer_name.AutoCompleteCustomSource = collection;