Search code examples
c#application-settings

Properties.Settings will not be saved


I'm trying to save two user values (SliderWidth and SliderHeight). I want to do this with the Visual Studio option settings.

The Visual Studio option settings

When I debug this with this code:

    public void Test(int value)
    {
        Properties.Settings settings = Properties.Settings.Default;
        settings.SliderWidth = value;
        settings.Save();
    }

The values ​​do not change (after the program ended).

What's wrong?


Solution

  • It definitely works. Try this:

    public void Test(int value)
    {
        Properties.Settings settings = Properties.Settings.Default;
    
        MessageBox.Show("Last SliderWidth = " + settings.SliderWidth.ToString());
    
        settings.SliderWidth = value;
        settings.Save();
    }
    

    But the saved value won't be reflected in the Designer window you are showing in your screen shot. Those are the initial default values.