This is a curiousity question geared towards databinding (and possibly CSLA)... ProjectTracker > PTWin > ProjectEdit.cs has an editable root project object with its 'resources' collection databound towards the bottom of the control.
There are 2 bindingsources on the control related to this Project -> Resources object hierarchy: projectBindingSource & resourcesBindingSource.
projectBindingsource has a datasource of 'ProjectTracker.Library.Project' and resourcesBindingSource is set to 'projectBindingSource' with a DataMember of 'Resources'.
I am unsure as to why 2 bindingsources are needed? The resources collection of a project is displayed in a DataGridView control with its datasource set to the resourcesBindingSource. If I were to changed the datasource of the DataGridView control to point to projectBindingSource and change its datamember property to be 'Resources' (basically moving the databinding off of a bindingsource control and putting it directly on the UI control) I get the same runtime result... I think?
Can someone explain what function is served by keeping the child collection's databinding in a seperate bindingsource? I was thinking it had something to do with BeginEdit()'s needing to be called on bindingsources directly or something.... Thanks in advance.
This is the result if you do drag-and-drop from the Data Sources window to set up the bindings on the controls. I always use drag-and-drop binding to bind my controls, as I find that to be more reliable than doing the bindings by hand.
However, if setting the DataMember by hand works for you and makes your world simpler, then go for it! :)
Well the value add is the SaveProject code can now be removed of any child bindingsource references, and using generics I can now have 1 method that will take care of all UI-Root Business object saving. I try to promote tight coupling when I am given the opportunity!
Copyright (c) Marimer LLC