简体   繁体   中英

How to organize saving of form settings of multiple forms with child forms

For saving form properties I will likely use some sort of xml serializer. But I have several forms with child forms. So there can be two-three different type of (main) forms, where both can have several types of child forms. The forms are all added dynamically, except for the main form.

So how would I best handle save/load of settings for this? Should each form have it's own setting file? And who shall be responsible for saving/loading each form? Would appreciate some tips and tricks..

I had a similar problem long time ago. We're using the XmlSerializer to accomplish that. The basic idea was, that we'd created aa class, that has an array of forms. Every time a new form was created, we'd added it to the array (removed it when form was closed).

The saving and loading was easy enough. At application start, we'd loaded the deserialized the xml file. And right after Application.Run(form) we'd put the save methods.

Maybe this is not best practice, but it just worked well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM