We have an application which contains database as xml files. It has client server architecture. So here server will read data from xml file by using dataset and store it in xml schema. Then server will serialize the data and pass it to the UI(client).So UI data’s are displayed by using Treeview on leftside, listview on right top and propertygrid on right bottom.
Data’s in Ui are categorized in to classes and objects. So now we have an xml file machinesclass.xml and machineobjects.xml in our database. machinesclass.xml contains various classes like electronic class,computer classs,agriculturetool class etc and machineobjects.xml contains TV,pentium4 computer,Tractror etc. So now in UI if I select electronic node from treeview ,it will list TV,radio,telephone etc what ever objects it contains in right top part by using Listview and if I select object "TV" related properties of TV are shown in propertygrid on right bottom.
So now we have a task that if somebody wants to take back up of selected objects from UI in terms of xml file(.xml), from parent machinesclass.xml and machineobjects.xml
for example if somebody selects TV from UI listview and wants to take back up in terms of .xml file(tv.xml) so that after sometime he can import data , what logic we can implement here? Can I serialize listview and propertygrid, or is there any options to do that? This is a bit of code i am using for copy paste operation within UI
Here is how to serialize a ListView:
http://www.codeproject.com/Articles/3335/Persist-ListView-settings-with-serialization
Here is how to serialize a PropertyGrid:
http://www.codeproject.com/Articles/27326/Load-and-Save-Data-Using-PropertyGrid
My advice is to do it properly, and I think the correct solution would be to serialize the business objects that the ListView and PropertyGrid are bound too. Separate the business logic from the GUI, then its really easy!
Edit (after OP edited question to show code):
To Save Data to the XML file:
To Read Data in from an XML file:
Here's how you do it with a PropertyGrid: PropertyGrid.Serialize