I'am struggling with the following, I have a datatable with some columns what i want is to have the items in this column displayed in a combobox. But it must not display double items.
How can i do this?
I'am struggling with the following, I have a datatable with some columns what i want is to have the items in this column displayed in a combobox. But it must not display double items.
How can i do this?
Try this:
private void FillComboFromColumnIndex(int columnIndex){
yourDataTable.AsEnumerable()
.Select(r=>r[columnIndex])
.Where(x=>x != null)
.Distinct().ToList()
.ForEach(x=>yourComboBox.Items.Add(x));
}
//To add all the items in column at index 1, do this
FillComboFromColumnIndex(1);
Try this, I'm not sure is it right answer on your question because I'm not sure if I have understood you as well: Hidden Id With ComboBox Items?