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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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: