views:

31

answers:

1

Using a BindingSource attached to an ObservableCollection I have a combobox displaying the items in the collection. Visual Studio automatically includes a BindingNavigator so I've enabled some features on that as well. Using the Add button to add a new item; the combobox automatically selects the new item. I assume this is because the BindingSource has updated it to reflect the fact that its current item has changed. My question is; can I stop the bindingsource automatically navigating to whatever I've just added and thus stop the combobox changing selection when I don't want it to? I don't want to hack either the combobox or the bindingsource to force it to maintain state, if I can avoid it.

+1  A: 

I don't think you can avoid that behavior, if you want to use an automatic bindingsource i think you're stuck with it. If you try to find a hack to resolve this issue, you're probably gonna run into even bigger issues. My solution would be to bind the combobox manually, and just use the automatic binding on whatever control you're using to actually add and modify the data.

scripni
Well that's fairly disappointing - you'd have thought they'd at least give us a behaviour property to set or something. I suppose reimplementing IBindingList is a fairly reasonable way of going about it, but a bit of a pain that it's necessary.
Tom W
In my opinion it has a fairly good all-round functionality, i agree that it's not very customizable but i believe it was built for simple databinding scenarios, so as not to overwhelm a novice developer that wants to see what that button does. A lot of the out-of-the-box .net controls give me that impression.
scripni