0
我在我的winform中有一個文本框。我想用客戶表中的手機號碼自動填充它。我已經編寫了代碼,但沒有自動完成。自動完成文本框
string CS = "data source=.; database=BillingSoftware; user id=sa; Password=9495640";
SqlConnection con = new SqlConnection(CS);
con.Open();
SqlCommand cmd = new SqlCommand("SELECT Phone FROM Customers", con);
SqlDataReader rdr = cmd.ExecuteReader();
AutoCompleteStringCollection CustomerPhone = new AutoCompleteStringCollection();
while (rdr.Read())
{
CustomerPhone.Add(rdr.GetString(0));
}
txt_customerPOS.AutoCompleteCustomSource = CustomerPhone;
con.Close();