allow only distinct values in ComboBox
- by Ravinder Gangadher
In my project, I am trying to populate ComboBox from DataSet. I succeeded in populating but the values inside the ComboBox are not distinct (Because it just showing the values present in DataSet). I cant bind the ComboBox to DataSet because I am adding "Select" text at first of populating the values. Here is my code.
ComboBox --> cmb
DataSet --> ds
DataSet Column Name --> value(string)
cmb.Items.Clear();
cmb.Items.Add("Select");
for (int intCount = 0; intCount < ds.Tables[0].Rows.Count; intCount++)
{
cmb.Items.Add(ds.Tables[0].Rows[intCount][value].ToString());
}
cmb.SelectedIndex = 0;
My question is how to allow distinct values (or restrict duplicate values) inside the ComboBox.