Binding Issue - 1 Dropdown with 2 sub drops, changing sub causes EditValueChanged 2x on parent

Binding Issue - 1 Dropdown with 2 sub drops, changing sub causes EditValueChanged 2x on parent

Old forum URL: forums.lhotka.net/forums/t/5542.aspx


awbacker posted on Monday, October 06, 2008

I have a form with a series of 3 combo boxes (devexpress lookupedits, really) on a form, and I am having issues with databinding.

All 3 combo boxes are bound to the same base object, different properties.  When I change Combo1, it populates the datasources for the other 2 (they are identical, but I set up separate data sources to be safe, for now).   **All of the bindings are set to OnPropertyChanged** as the DataBinding setup.

The first combo has the EditValueChanged event, which is what this logic goes in.   Under certain conditions, the event is fired twice, once by Combo1, and then again when I change the EditValue of Combo2 or 3.

Combo1_EditValueChanged

Some unrelated logic
bindingSource2.datasource = (get new data)
bindingSource3.datasource = (get new data)
Combo2.EditValue = ""  '-- already has a value
Combo2.EditValue = ""  '-- already has a value
^^^ one of these two somehow triggers Combo1_EditValueChanged again

1) Select a value in combo1 - EditValueChanged fires, everything OK
2) Select a value in combo2 (popuplated normally, this is the first time)
3) Change the value in combo1
4) EditValueChanged is fired
5) In EditValueChanged : combo2 = "", which somehow causes the event to fire again

The issue is that when the event is fired for the 2nd time, the EditValue of Combo1 is somehow reset to the original!  During all of this, the underlying value of the object is *never* set to the EditValue.   It seems, when I trace through it, that calling the Value="" on Comb2 causes the proper property on the underlying object to be set, but immediatly after that I get another call to the OTHER property, the one for combo 1, which is the original value.

Is there some way that I can handle this, or something that I am doing wrong?  I was hoping that EditValue would be posted to the object by the time this was done. 

I doubt this is a DevExpress thing, but I wasn't sure.  I have the BindingSourceRefresh control on the form, and I do need to have the OnPropertyChanged set for the databindings.

Thanks,

//Andrew

Copyright (c) Marimer LLC