How you bind data grid with data?
The idea is: you should not save any data from controls immediately to file. This design is hard to maintain. You need to have a separate data layer, whatever it is and bind it to you UI controls and save your data from you data layer, not from control. Even of you don't use data binding, it means you bind this control through "manual" code, the design should be the same: you populate data from data layer to view, editing of the view should invalidate data and synchronize it with data layer, changes in data layer should update the view. The closest
architectural pattern for this approach is MVC.
I suggest you learn and analyze applicability of the following
architectural patterns (
http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)[
^]):
MVVM — Model View View Model,
http://en.wikipedia.org/wiki/Model_View_ViewModel[^],
MVC — Model-View-Controller,
http://en.wikipedia.org/wiki/Model-view-controller[^]),
MVA — Model-View-Adapter,
http://en.wikipedia.org/wiki/Model–view–adapter[^],
MVP — Model-View-Presenter,
http://en.wikipedia.org/wiki/Model-view-presenter[^].
Pay attention for the motivation of those architectures. If you understand it, you would be able to create better design ideas.
—SA