【问题标题】:Storing a DockPanel in a settings file将 DockPanel 存储在设置文件中
【发布时间】:2012-06-23 04:59:46
【问题描述】:

我正在尝试将 DevExpress DockPanel 存储在设置文件中。一切似乎都在保存功能中工作,但是当我在启动应用程序时加载它时,Settings.Default.WebLayoutPanel 变量为空:这是保存:

Settings.Default.VisibilitySwitchesPanel = _visibilitySwitchesPanel;

这是负载

如果 (Settings.Default.WebLayoutPanel != null)

{ _webLayoutPanel = Settings.Default.WebLayoutPanel; }

关于它为什么为空的任何想法?

【问题讨论】:

    标签: c# visual-studio-2010 devexpress settings dockpanel


    【解决方案1】:

    您不应将Control 实例直接保存到应用程序设置中。这是错误的方式。您应该使用自定义可序列化包装器保存这些控件的特定设置,然后恢复这些设置。这是一个有用的链接:

    1. Windows Forms - Creating and Persisting Custom User Settings in C#
    2. Using Application Settings and User Settings

    对于 DevExpress DockPanels,当您想要保存/恢复停靠布局时,您应该使用嵌入式保存/恢复功能:Saving and Restoring the Layout of Dock Panels

    【讨论】:

    • 你是对的,这是存储我的面板的错误方式。如果你不介意我问为什么你从来没有问过关于 SO 的问题却回答了这么多?
    • @John:我喜欢不时回答关于 SO 的问题,但我还没有自己无法回答的问题……或者 Google 无法回答))
    • 即使我们没有机会帮助您,我们也非常感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-07-30
    • 2017-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多