If you’ve been frustrated by Whidbey’s Windows Forms
support for application settings management here’s a tip that may help you.
There are two major bits of functionality involved. The
first is the support for reading and writing the xml configuration files for
both user and application settings. The second is the support for creating
Binding objects to tie the settings properties to various object properties in
your application.
The Binding stuff is much more broken than the xml
read/write stuff.
My suggestion is to not use the “Application Settings” on
the Property panel. It invariably shoots me in the foot, scrambling the
*.Designer.cs files with random settings getting stuck where they don’t belong.
Instead, take charge of manually transferring the
properties to and from the Properties.Settings.Value object. Right after
InitializeComponent(), copy them out, and right before
Properties.Settings.Value.Save() copy them back.
All the truly mysterious behavior of when user config
files were and were not written, as well as random changes to the applications
UI, disappeared after I eliminated all the automatically generated Binding
objects.
I did try manually creating the Bindings, but the bugs
seem to be inherent in the code that identifies actual object fields to update
based on the state of the Binding objects. It seems to just get it wrong with
painful regularity.
It is just beta code after all J
Here’s an MSDN
article that I found useful. Specifically, it answered why some settings
are read-only wile others are read-write. Obvious once you think about it!
I’m looking forward to when it all works smoothly…
this.button1.DataBindings.Add(new
System.Windows.Forms.Binding("Font", SettingsTest.Properties.Settings.Value, "ButtonFont",
true, "",
null, System.Windows.Forms.BindingUpdateMode.OnPropertyChanged));