This is my function that is loading some values to a comboBox:
void comboFill()
{
try
{
string connectionString = "Data Source=D\\SQLEXPRESS;Initial Catalog=Inventory;Integrated Security=True";
SqlConnection con = new SqlConnection(connectionString);
con.Open();
string query = "SELECT * FROM dbo.Inven; ";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
string invDes = dr.GetString(dr.GetOrdinal("Description"));
comboBox1.Items.Add(invDes);
}
con.Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
How would I use "contains" to check for a character and then display the comboBox while I type? For eg. the comboBox would have the items: cat, bird, billy. And when I type the letter "i" it brings up "bird" and "billy" in the dropdown of values. I know it is something like this:
if (comboBox1.Items.Contains("some value")){}
But am not entirely sure how to implement it in this case. To clarify I do not want an autocomplete comboBox as this does not take into account substring searches.