Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# settings GUI

I wrote my first C# program a while ago. It got somewhat big. My .settings file has over 20 different parameters - booleans, sizes, strings, ints. I'd like to provide users with a GUI to change them during runtime instead of editing the app.exe.config file which is somewhat advanced and confusing.

I'm very inexperienced with C# but seems like there should be a better way than for me to manually create a form, drag in labels, inputs, checkboxes, radio buttons, and manually handle all gui events and what happens when values get changed and whatnot. Building this gui by hand seems like a lot of work.

How do you guys handle the settings of a C# app? Can't I generate something from the XML?

like image 424
user1340531 Avatar asked May 15 '26 12:05

user1340531


1 Answers

In WinForms applications you can add a control to a Form and then click the (PropertyBinding) under (ApplicationSettings) in the Property box.

The dialog allows you to bind properties of the control to a parameter in the config file. It is an extra step during design but it must be done.

These settings will end up in the user config file (I strongly advise against the application config file for this)

You will have to provide the user with a way to specify these settings by either:

  1. having the user edit the config file - very dangerous because it is very easy to mess that up.
  2. allowing the user to manipulate the UI (drag-drop) and save the settings from code. - a lot of work to prevent the user painting himself in a corner.
  3. a separate/standalone designer application that combines 1. and 2.
like image 178
Emond Avatar answered May 18 '26 02:05

Emond