0

I use the Properties.Settings.Default to save the user settings of my program. This includes the size and position of the Main Window. See the Picture here. These represent the default values asigned when I call

Properties.Settings.Default.Reset();

When I call

Properties.Settings.Default.Height = 25;

for example, the user setting gets saved as 25 by calling

Properties.Settings.Default.Save();

When I now go for reset() and save(), the default value I chose in the Picture are again given back when calling

Properties.Settings.Default.Height;

How can I change these default values during runtime so that when I call reset(), my newly assigned values are being taken? (Even when I close the program and reopen again. It should consequently update in the Picture as well)

Heldenkrieger01
  • 338
  • 3
  • 16
  • 1
    I feel as though you may be using default values improperly. Default values usually should not change at runtime as they would no longer be default - but rather, dynamic. – Chris Cruz Aug 08 '17 at 15:17
  • Am I able to set dynamic default values, for example the size of the users screen? @ChrisCruz – Heldenkrieger01 Aug 08 '17 at 20:18
  • _"How can I change these default values during runtime so that when I call reset(), my newly assigned values are being taken?"_ -- I don't understand your question. What is the point of the `Reset()` method, if you want it to _not_ reset the values? And if you want to _not_ reset the values, wouldn't it be better to just not call `Reset()` instead of trying to change the default values to whatever is currently set? – Peter Duniho Aug 09 '17 at 00:05
  • Possible duplicate of https://stackoverflow.com/questions/523619/how-can-i-set-application-settings-at-install-time-via-installer-class – Peter Duniho Aug 09 '17 at 00:10

1 Answers1

1

Changing Settings.Default shouldn't be a problem if parameters scope set to User. Parameters in Application scope are read-only. Here is my setup.

Settings.Default example

Then I use it in public field for two way binding like so.

public double CurrRateRubToUSD
    {
        get
        {
            return Properties.Settings.Default.CurrencyRateRubToUSD;
        }
        set
        {
            if (value != Properties.Settings.Default.CurrencyRateRubToUSD)
            {
                Properties.Settings.Default.CurrencyRateRubToUSD = value;
                Properties.Settings.Default.Save();
                Properties.Settings.Default.Reload();
            }
        }
    }