Removing a listitem from a Databound ComboBox?
Posted on 2014-10-28
I have 2 combobox controls on a windows form. They are both bound to a DataTable and contain Identical data. When a user selects the data, each selected item has to be different. I created a subroutine that would eliminate the selectedIndex in the second combobox but when it executed, it threw the followig exception:
"Item collection cannot be modified when the DataSource property is set".
So, in order to make sure they can't select duplicate data, is there any way to remove an item from a ComboBox that is bound to a DataTable. The work-around is to simply display a message to the user indicating that they have made a duplicate selection but I would rather avoid that and address it in the ComboBoxes!