With this code:
comboBoxCurrently.DataSource = PlatypusData.getCurrentlyVals();
comboBoxCurrently.Items.Remove("Surrounded by purplish-blue Penguins");
…I get, “System.ArgumentException was unhandled
Message=Items collection cannot be modified when the DataSource property is set.“
I don’t want to restrict the value I’m later removing from within the query (…WHERE bla <> ‘Surrounded…), because sometimes that value IS allowed (to display historical data), and I don’t really want to have a conditional statement in getCurrentlyVals() that uses either one query statement or the other (if there is a better way to do it).
Any ideas?
UPDATED
OK, this worked:
List<string> intermediateList = PlatypusData.getCurrentlyVals();
intermediateList.Remove("Surrounded by purplish-blue Penguins");
comboBoxCurrently.DataSource = intermediateList;
UPDATED AGAIN
I changed that to Lars’ way:
comboBoxCurrently.Items.AddRange(PlatypusData.getCurrentlyVals().ToArray());
comboBoxCurrently.Items.Remove("Surrounded by purplish-blue Penguins");
…and I reckon this page has more intances of the string “Surrounded by purplish-blue Penguins” than any page in the history of mankind, past or future.
You would have to modify the collection from the DataSource, but you seem to be against doing that, so in that case, don’t use a DataSource, but try adding the items to the ComboBox directly: