P
Peter
Hi!
I am having some very strange behavior with my databound controls. It's
taken a long time to isolate exactly what is provoking the problem, but I'm
still leagues away from solving it.
I have a DataView which filters a DataSet. Bound to this dataview is a
ListBox, via its DataSource property. The DisplayMember is the name property
of the row. Simple enough so far?
There is a button which adds a new row to the DataSet (directly, not via the
DataView). This seems to work fine in isolation and the change appears in
the DataView. There is also a button which rejects the changes made to the
DataSet. No problem.
Now, I add a TextBox to the form, bound to the same DataView (via the
TextBox's DataBindings collection). I want it to show a property of the
selected row in the ListBox, so it must use the same BindingContext.
Unfortunately, here is where things get bizarre. Suddenly, when I click the
button to add a new row, I not only get a new row with my parameters, but I
get a second "virtual" row which shows up merely as
"System.Data.DataRowView". And when I click the RejectChanges button, that
row doesn't go away. Clicking on it will sometimes crash the program as the
CurrencyManager tries to update all the bound controls, since the
System.Data.DataRowView seems not to be a real object... it just *looks*
like one.
Why is it doing that? Does this situation sound familiar to anyone? I can't
seem to duplicate the behavior in a test solution, either. I thought I read
somewhere that one shouldn't combine simple and complex databinding to the
same source, but how then can I use a TextBox to show a property of the
currently selected row?
I am having some very strange behavior with my databound controls. It's
taken a long time to isolate exactly what is provoking the problem, but I'm
still leagues away from solving it.
I have a DataView which filters a DataSet. Bound to this dataview is a
ListBox, via its DataSource property. The DisplayMember is the name property
of the row. Simple enough so far?
There is a button which adds a new row to the DataSet (directly, not via the
DataView). This seems to work fine in isolation and the change appears in
the DataView. There is also a button which rejects the changes made to the
DataSet. No problem.
Now, I add a TextBox to the form, bound to the same DataView (via the
TextBox's DataBindings collection). I want it to show a property of the
selected row in the ListBox, so it must use the same BindingContext.
Unfortunately, here is where things get bizarre. Suddenly, when I click the
button to add a new row, I not only get a new row with my parameters, but I
get a second "virtual" row which shows up merely as
"System.Data.DataRowView". And when I click the RejectChanges button, that
row doesn't go away. Clicking on it will sometimes crash the program as the
CurrencyManager tries to update all the bound controls, since the
System.Data.DataRowView seems not to be a real object... it just *looks*
like one.
Why is it doing that? Does this situation sound familiar to anyone? I can't
seem to duplicate the behavior in a test solution, either. I thought I read
somewhere that one shouldn't combine simple and complex databinding to the
same source, but how then can I use a TextBox to show a property of the
currently selected row?