Storing a DockPanel in a settings file
-
16-06-2021 - |
Pergunta
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:
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?
Solução
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:
- Windows Forms - Creating and Persisting Custom User Settings in C#
- 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