Problem with data bound master - detail

Brady Kelly <[email protected]> Wed, 17 Oct 2007 11:44:02 +0200
Newsgroups gmane.comp.windows.devel.dotnet.winforms
Message-ID <[email protected]>
I have a DataSet called 'exportDefsDataSet', with two tables, 'ExportDef'
and 'ExportDefItem'.  The data set contains a relation,
'ExportDef_ExportDefItem' that relates the two on ExportDefID.  This
represents a set of export definitions, and definition items within the
export definition, i.e. one export definition has many items.



I have a form with two binding sources on it, 'exportDefBindingSource' and
'exportDefItemBindingSource'.  The DataSource of the 'parent' binding source
is set to 'exportDefsDataSet' and the DataMember to 'ExportDef'.  The
DataSource of the 'child' binding source is set to 'exportDefBindingSource',
and the DataMember to the relation 'ExportDef_ExportDefItem'.



I have a ComboBox bound to  'exportDefBindingSource' and a BindingNavigator
and two textboxes bound to 'exportDefItemBindingSource'.  When I select an
export definition in the combobox, I can navigate between the definition
items for that definition, but chaos ensues, as often the selected
definition disappears from the combo box, or the items for another
definition appear in the textboxes.  I am battling to reliably preproduce
this behaviour, as often the setup works correctly, and after after a
seemingly random number of navigations does everything go bad.



Let me describe a typical scenario:



I start the application, and the first definition, "Access Accounting" is
automatically selected, and the BindingNavigator correctly navigates between
the items for "Access Accounting".  The next definition is "AccpPac DOS",
and if I select it, the correct items for "AccPac DOS" are available, BUT,
"Access Accounting" is no longer visible in the ComboBox!  Now there are two
"AccPac DOS" entries, and the first one of them selects the items for
"Access Accounting".  Now I select a third option, "AMS", and get the AMS
items, but now I have two AMS entries, and the first one still points to the
"Access Accounting" items.  The ComboBox is thouroughly out of sync, but I
can't find why.