alanmusician
Programmer
I'm having an issue with the combobox when binding to SelectedValue. ValueMember and DisplayMember are bound to a collection of custom objects as "Id" and "Species". SelectedValue is bound to another custom object as "SpeciesID". The collection is loaded from a database.
This all works quite well except when adding a new item to the collection. Here is what happens:
A new item is added to the collection by the user. The new item is created with an "Id" of 0. When the item is selected, the SelectedValue changes to 0, and propagates to "SpeciesID" as expected. Now, when the item is written back to the database, the "Id" gets set to 5 or whatever, and so SelectedValue turns to "5" as well. It does not, however, propagate to "SpeciesID" even though they are bound, and work correctly under all other circumstances.
Another oddity: I can set a watch on SelectedValue and watch it change from 0 to 5 on the line of code that sets "Id", but the OnSelectedValueChange event never fires.
Does anyone know why I am getting such odd behavior?
Thanks,
--Alan
This all works quite well except when adding a new item to the collection. Here is what happens:
A new item is added to the collection by the user. The new item is created with an "Id" of 0. When the item is selected, the SelectedValue changes to 0, and propagates to "SpeciesID" as expected. Now, when the item is written back to the database, the "Id" gets set to 5 or whatever, and so SelectedValue turns to "5" as well. It does not, however, propagate to "SpeciesID" even though they are bound, and work correctly under all other circumstances.
Another oddity: I can set a watch on SelectedValue and watch it change from 0 to 5 on the line of code that sets "Id", but the OnSelectedValueChange event never fires.
Does anyone know why I am getting such odd behavior?
Thanks,
--Alan