More Databinding trouble

More Databinding trouble

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


razorkai posted on Wednesday, September 13, 2006

Sigh, here we go again!  If I have a BusinessListBase derived collection of objects and I use databinding to link a BindingSource to one of the collection's child objects, why does BeginEdit get called automatically on the child object?  I am using a Treeview with each node holding a reference to one of the child business objects.  When the user selects a node in the treeview, a UserControl on the form has its BindingSource updated to point at the object e.g.

MyBindingSource.DataSource = myObject; //this calls BeginEdit

So each time the user selects a different node, the BindingSource gets bound to the appropriate object but the object it was bound to stays at EditLevel 1.  So I end up with a whole selection of objects above the EditLevel I believe they should be at (i.e. zero).  Surely the BeginEdit method should only be called when the object is actually being edited rather than just displayed?

RockfordLhotka replied on Wednesday, September 13, 2006

In .NET 1.x they were lazy about calling BeginEdit, but in .NET 2.0 it does appear that they are much more aggressive and so BeginEdit is called right away - even if the user hasn't attempted to perform any edit of data in a control...

Copyright (c) Marimer LLC