Auto complete textbox with multiple value from database.how
I have a text box in my windows form application which allows the user to enter email addresses. I want to include the auto suggest and auto complete feature which is same as that of "to" address filed of outlook where whenever couple of characters entered, it gives the matching email address and so on. Here I have to fetch the email addresses from user table.
IN the form laod even I will write the below code.
private void Form1_Load(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("Select distinct Location from Employee_Table order by Location asc",con);
cmd.CommandType = CommandType.Text;
SqlDataReader dr;
dr= cmd.ExecuteReader();
if (dr.HasRows == true)
{
while (dr.Read())
namesCollection.Add(dr["Location"].ToString());
}
con.Close();
txtLocation.AutoCompleteMode = AutoCompleteMode.Suggest;
txtLocation.AutoCompleteSource = AutoCompleteSource.CustomSource;
txtLocation.AutoCompleteCustomSource = namesCollection;
}
}
}
Here i can able to populate the first entry from the database. but when I enter semicolon(;) and try entering fro the next email adddress,it wont populate. PLease help.