Dynamically loaded items in combobox
Posted on 2004-08-23
i've got a problem using a combobox that should display dynamically loaded items. till now i only worked with comboboxes that items were loaded once at startup. i used the datasource-property that i linked to an IList consisting of objects. these objects had the following structure:
string Object.Display - the value that should be displayed by combobox
string Object.Value - the key in the back to be used for further processing
i mapped the Display-property to comboboxes Displaymember-property and Value-property to Valuemember. Nice thing - did it well. But it does not work if you want to change the items of the combobox while working with it.
I remember having encountered the problem with listboxes, too. there i solved it forgetting the DataSource-property and using the old-style Items-property. Via the Items.Add-method i added all my items, via Items.Clear the collection was emptied to be filled with new data. That works well with Listboxes. But it seems not to be working with comboboxes?
does anyone of you know a nice solution to this problem?
thanks in advance.