如何组织保存具有子表单的多个表单的表单设置

发布于 2024-12-23 08:05:43 字数 177 浏览 0 评论 0原文

为了保存表单属性,我可能会使用某种 xml 序列化程序。但我有几种带有子表单的表单。因此,可以有两到三种不同类型的(主)表单,其中两者都可以有多种类型的子表单。除主窗体外,所有窗体都是动态添加的。

那么我该如何最好地处理此设置的保存/加载呢?每个表单都应该有自己的设置文件吗?谁负责保存/加载每个表格?希望有一些提示和技巧。

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..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空‖城人不在 2024-12-30 08:05:43

很久以前我也遇到过类似的问题。我们使用 XmlSerializer 来实现这一点。基本思想是,我们创建了一个具有一系列形式的类。每次创建新表单时,我们都会将其添加到数组中(关闭表单时将其删除)。

保存和加载非常容易。在应用程序启动时,我们加载了反序列化的 xml 文件。在 Application.Run(form) 之后,我们将放置保存方法。

也许这不是最佳实践,但效果很好。

I had a similar problem long time ago. We're using the XmlSerializer to accomplish that. The basic idea was, that we'd created a a 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文