Question : Adjust a bound combobox.

Hello, I hope some experts can help me out on this one. I have a combo box that is bound to a dataview and the data view is populated from an xml file saved localy. The users make selections on the comboboxes and then save it. I have an updated xml I want to put in but it has some values added and removed. This would not be a problem moving forward, but if the older saved files contain one of the deleted values it will not be selected when the combobox loads the saved data.

I need a method like "SelectOrAddItemToComboBox()"

I load my combobox from the saved data  like: WellComboBox.Text = myData.WellType;
at this point I have already bound the combobox and it contains all the items, here is also do not have access to the dataview that I used to bind to the combobox.

If anyone has any suggestions on how to accomplish this please let me know

Answer : Adjust a bound combobox.


Just got a thought...

Thought you dont have access to the DataView before binding...still that dataview is available in DataSource property of the combo...

// combobox bound to dataview here

// now it is available in DataSource property

DataView dataView = (DataView) comboBox1.DataSource

DataTable dataTable = dataView.Table;

// Now add new row to DataTable with the old value of WellType
// this will automatically update the combo box.

See if this will work for you.

Random Solutions  
 
programming4us programming4us