0

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?

jth41
  • 3,808
  • 9
  • 59
  • 109

1 Answers1

1

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

DmitryG
  • 17,677
  • 1
  • 30
  • 53
  • You are correct, this is the wrong way to store my panels. If you dont mind me asking why have you never asked a question on SO but answered so many? – jth41 Jun 25 '12 at 00:57
  • @John: I like to answer on SO from time-to-time, but I have no questions yet which I can't answer myself... or Google can't )) – DmitryG Jun 25 '12 at 04:21
  • Well your help is appreciated even if we havent had the oppertunity to help you back. – jth41 Jun 25 '12 at 04:34