我通过从数据库创建列表动态填充winforms组合框。检查项目是否在组合框列表中
List<string> locationList = new List<string>();
foreach(Data.DataSet.vwGet_RepListRow row in Data.Manager.TAM.RepListViewTableAdapter.GetData())
locationList.Add(row.Location_City);
this.LocationComboBox.DataSource = locationList;
我遇到的问题是,有现在一共有3个位置,但65名员工因此正在发生的事情是我得到在组合框中反复城市。我如何编辑上面的内容来检查新的Location_City是否已经不在locationList中?如果它不在那里,然后添加它,但如果它在那里,则跳过它。
任何帮助将是伟大的。
您还可以使用HashSet的;看我的编辑。 – 2010-11-11 14:46:34