AutoCompleteStringCollection treatmentCollection = new AutoCompleteStringCollection();
if (con.State == ConnectionState.Closed)
{
con.Open();
}
SqlCeCommand cmdTreatment = new SqlCeCommand("select Treatment from NewPatient", con);
SqlCeDataReader readerTreatment = cmdTreatment.ExecuteReader();
if (readerTreatment.Read() == true)
{
while (readerTreatment.Read())
{
treatmentCollection.Add(readerTreatment["Treatment"].ToString());
}
}
comboBox2.AutoCompleteMode = AutoCompleteMode.Suggest;
comboBox2.AutoCompleteSource = AutoCompleteSource.CustomSource;
comboBox2.AutoCompleteCustomSource = treatmentCollection;
if (con.State == ConnectionState.Open)
{
con.Close();
}
我希望combobox2
应该只有不同的价值。treatmentCollection
并且组合框从类对象中获取价值AutoCompleteStringCollection
请帮助我?