문제

I am attempting to store a DevExpress DockPanel in a settings file. Everything appears to work in the save function, but when I go to load it upon starting the application, The Settings.Default.WebLayoutPanel variable is null: here is the save:

enter image description here

Settings.Default.VisibilitySwitchesPanel = _visibilitySwitchesPanel;

and here is the load

if (Settings.Default.WebLayoutPanel != null)

{ _webLayoutPanel = Settings.Default.WebLayoutPanel; }

Any Ideas as to why it is null?

도움이 되었습니까?

해결책

You should not save the Control instances directly into the application settings. It's a wrong way. You should save the specific settings of these controls using custom serializable wrapper and then restore these settings. Here is a useful links:

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

As for DevExpress DockPanels, when you want to save/restore the docking layout you should use the embedded save/restore functionality: Saving and Restoring the Layout of Dock Panels

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top