我用下面的代码填充“来自数据库的列表框”,并希望通过列表框中具有AutoCompleteMode的文本框进行搜索。请问如何做?
public void refreshdata()
{
//DataRow dr;
SqlConnection cn = new SqlConnection(@"Server=.\SQLEXPRESS; DataBase=Gestion Cabinet; Integrated Security = true;");
cn.Open();
SqlCommand cmd = new SqlCommand("select * from Médicaments", cn);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
listBox1.Items.Add(ds.Tables[0].Rows[i][1]
+ " " + ","
+ ds.Tables[0].Rows[i][2]
+ " " + ","
+ ds.Tables[0].Rows[i][3]);
cn.Close();
}