I'm trying out Visual Studio's auto complete for textbox and so far it's doing good but I currently am having problems on how could I improve the suggestions since as for now, it only shows the words starting with the letter I type sorta if I typed a, it would show Apple, Ant, Axe. I kinda wanted it to also suggest words that doesn't start with a but still has that a letter inside them, words like Zebra, Camel, Boat, Bear.
Here's my current code:
void AutoCompleteText()
{
Search_text.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
Search_text.AutoCompleteSource = AutoCompleteSource.CustomSource;
AutoCompleteStringCollection coll = new AutoCompleteStringCollection();
SqlCommand cmdDataBase = new SqlCommand("SELECT * FROM item", sc);
SqlDataReader textboxReader;
try
{
sc.Open();
textboxReader = cmdDataBase.ExecuteReader();
while(textboxReader.Read())
{
string sName = textboxReader["item_name"].ToString();
coll.Add(sName);
}
sc.Close();
}
catch(Exception ext)
{
richTextBox1.Text = ext.ToString();
}
Search_text.AutoCompleteCustomSource = coll;
}
(Sorry for the incredibly long title, I just wanted to explain the entire dilemma on the title, the VS is for Visual Studio, I made it to VS as I will actually exceeded the 150 character limit if I make it Visual Studio)