如何在 .NET 中保留 MDI 布局?
我正在用 C# 编写 MDI 应用程序。我想要一种方法来存储所有打开的窗口的位置和内容,以便用户可以自定义查看多个文档的方式。有没有一种简单的方法可以做到这一点,或者我必须推出自己的解决方案?
I'm writing an MDI Application in C#. I'd like a way to store the positions and contents of all the open windows, so that a user can customize the way multiple documents are viewed. Is there a simple way to do this, or will I have to roll my own solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我见过一些形式的持久性类,但它们并没有完全满足我的需要。我最终推出了自己的版本,主要执行以下操作:
DoSave() 只是将此信息存储在用户空间中的某个 XML 文件中,但当然,您可以以不同的方式存储它。
在适当的时候,例如在启动时,我有一个 ReadSettings() 方法,它本质上反转了该过程,询问保存的设置,设置值。可能有一种更优雅的解决方案来解决这个问题,但这个解决方案对我来说非常有效。
希望有帮助。
I've seen a few form persistence classes around but they didn't do exactly what I needed. I ended up rolling my own, essentially doing the following:
DoSave() just stores this info off in some XML file in the user's space, but you could store it differently, of course.
When appropriate, such as at startup, I have a ReadSettings() method that essentially reverses the process, interrogating the saved settings, setting the values. There might be a more elegant solution to the problem, but this one has worked really well for me.
Hope that helps.