Reputation:
I'd like to save some / all properties of a control to xml. E.g. the column widths of listivew like
listView1.SaveToXml("listview.xml")
How's this possible?
Upvotes: 2
Views: 1392
Reputation: 17061
Via the XMLSerializer class.
And here's a good example of how to do it.
And, since Control's are not serializable, here is a way around that issue.
EDIT: Here are two more examples of how to do XML Serialization:
http://www.dotnetjohn.com/articles.aspx?articleid=173
http://devhood.mit.edu/Tutorials/tutorial_details.aspx?tutorial_id=236
As for exact code to do what you're trying to do, I realize now that we're actually using BinaryFormatter which is a little different from the way XMLSerializer does things, so providing code would not be useful to you. However, the algorithm is essentially:
Upvotes: 1