Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top