Search code examples
.netwinformsapplication-settings

Application settings without saving to app.config


Application settings in Windows Forms is a convenient way to store application-wide properties. However, on my current project, these settings are littered with color definitions which are more or less static, causing noise in app.config. Are there any good way of preventing settings from being written to app.config, simply relying on the default value?

I tried moving the settings in question out as resources, but as far as I can tell, the Windows Forms designer in Visual studio provides no means of assigning color resource values to properties on controls.


Solution

  • Application settings is the right place for all of this information. If you're worried about noise, build a class with properties to hold each of the color attributes you are saving. Mark the class up with the various [Serializable] attributes and you can place it in Application settings just like anything else. Now your "noisy" color settings are nested in the hierarchy and won't clutter up or drown out other, more significant, settings.