4

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.

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

While this was not the answer I was hoping for, I acknowledge the fact that this is how it is supposed to be solved.
1

You can use Settings, it's prepared especially for user/machine specific configuration. You can store there simple types or more complicated but then you'll have to (usually) serialize them to XML and store as string.

Comments

0

Do you have access to a database you could store key value pairs in? Either that, or if they can be transient then you could store them in a dictionary object in memory.

Storing in a resource file sounds like a good idea too. You could just write a routine to iterate through a set of key value pairs.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.