views:

229

answers:

3

Hi,

I am working in C#. I find myself creating dialogs for editing my application settings all the time. For every control on the dialog I am reading the configuration file and set it accordingly. After pressing OK, I am reading all the controls and store the values in the configuration files or something similar again.

This seems to be very time consuming, simple and repetitive. Does anybody have an idea how to simplify this process? Code generation? Helper classes?

Please make my life easier!

Erik

+1  A: 

Do these application settings dialogs need to be pretty or are they simply there for personal configuration? If it's the latter, read all the settings into a class and assign that class to a property editor.

Not recommended for a good-looking, final UI though.

rein
It has to look pretty!
Enrico
A: 

Best bet would be to use the "Settings" that are included in the default template for a winforms rather than "configuration" it is easier and the settings can be bound to just about any property for a control or read independently. Once discovered they are well documented, easy to customise and easy to use.

If you need to use configuration then I'd look at using a custom configuration section and bind that to a property grid or control set for editing. The configuration makes it easy to read and write changes to the configuration.

David McEwing
+1  A: 

You can bind WinForms controls directly to application settings, which should make your life a lot easier for creating dialogs to manage them.

Just select a control and look for the (Application Settings) option under the Data group in the properties pane. I put up a screenshot here to illustrate.

Colin Cochrane
Bingo! I knew I was missing on something. Thank you very much!!!
Enrico