1

Please forgive me if my thought process is incorrect. I'm only a programmer in my spare time, with no formal training.

I'm using VB.net to create a very basic application, but some settings need to be read on startup. So my theory is that in the Form1.Load area, add all the checks for various settings and apply the settings as needed.

Next, changing settings on the fly while the application is running. I see a few different possibilities:

  1. Create subroutines for each setting check. As each checkbox or radio button is clicked, call the appropriate sub-routine. As the form loads, run through all these subroutines.
  2. Call the Form1.Load subroutine on any settings change (larger programs, I could see this being VERY slow)
  3. Repeat myself, and execute the code as soon as the option is changed. Have the Form1.Load subroutine execute the settings check on every control, and remember to add newer settings to the sub as they get built or changed.

Option 1 seems to be the most logical in my head. Is this the most sustainable method for projects, or is there a better way to ensure settings change as the options change?

For example, I have a checkbox that controls whether the output window is a Fixed Width font, or a regular font. The check box gets and saves its settings to the App.config file, so the option is persistent across program starts.

3
  • 1
    You can actually bind Winforms controls to application settings. It seems daunting at first, but it's actually really easy once you get it.
    – RubberDuck
    Commented Mar 2, 2017 at 1:56
  • @RubberDuck details? I'd love to learn easier methods Commented Mar 2, 2017 at 1:59
  • stackoverflow.com/questions/3371118/…
    – RubberDuck
    Commented Mar 2, 2017 at 2:01

1 Answer 1

1

With help from RubberDuck's comments, I am able to use the Application Settings function built in to the .NET framework.

This is handling all the on-the-fly changes, as well as persistent changes throughout the program.

On each control that I want to change the settings with, I start by assigning the setting for the control. Then, I run the logic (i.e. If setting is true, set property x to y). Finally, I update the controls that get affected by the settings.

I then attach the setting to be changed to the control, and it handles everything on the fly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.