« debugging DataGrid behavior | Main | Automaticall removing old version during Setup & Installation »

DataGrid behavior

Form.Controls.Add of the DataGrid control (or of a control containing it) causes:

a.                   ListManager initialized.

b.                   Bound set to true.

c.                   BindingContext initialized to Form’s BindingContext.

d.                   IsHandleCreated still false.

e.                   DataBindings.Count still zero, this is independent of the BindingContext.

f.                     BindingContext collection has entries which are System.WeakReference’s to CurrencyManager or RelatedCurrencyManager objects. RCM’s extend CM’s. RCM’s have a parent reference to a CM.

a.       “” is CurrencyManager for entire data set.

b.        “job” is RelatedCurrencyManager.

g.                   grid.ListManager.GetHashCode() == grid.BindingContext[grid.DataSource, grid.DataMember].GetHashCode()
but
grid.ListManager != grid.BindingContext[grid.DataSource, grid.DataMember]

h.                   Form’s BindingContext == DataGrid.BindingContext

So far:

1.       The AllowNew DataView property must be set true prior to a Clear-Fill load dataset operation. Failing to do so will cause the Grid to stop accepting new values for existing cells.

 

Comments

Probably the RelatedCurrencyManager tried to insert a new row to the parent records and that thrown an exception.
See my site for info.
Possible solution is
1. update parents and remember parents need deletion
2. update childs
3. delete parent and childs remembered in 1.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)