gpt4 book ai didi

c# - 从 AutoCompleteStringCollection c# 中删除重复项

转载 作者:可可西里 更新时间:2023-11-01 11:33:57 24 4
gpt4 key购买 nike

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 应该只有不同的值。组合框从 AutoCompleteStringCollection 类的 treatmentCollection 对象获取值请帮帮我?

最佳答案

替换:

select Treatment from NewPatient

为此:

select distinct Treatment from NewPatient

关于c# - 从 AutoCompleteStringCollection c# 中删除重复项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16276312/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com