The project I came into manages databinding like this:
- Default object is loaded on form load.
- Object is databound to each control property by property in code.
- User selects a different object to view.
- All controls have their databindings cleared.
- All controls have a databinding added referencing the new object instead of the old.
I have seen some places in the code where previous developers used BindingManagerBase, but was unsure of the reason for it.
During my research it seems it is used to simplify databinding in the manner of PropertyManager but I can't figure out how to update it's "Current" property. Can it reduce the steps above to the following?
- Default object is loaded.
- Databindings added, and BindManager retrieved.
- User selects a different object to view.
- BindManager's reference of databount object is updated, propogating to all controls.
If not, is there an class capable of doing this?
Also is there any way that this can be done automatically with some property on the controls themselves.
Simply instantiate some hypothetical binding manager that looks for controls with a property set, and databinds them to an object specified, thus removing the need to programmatically databind each control to begin with?