How to write on Properties.Settings.Default in second Form? C#

100 Views Asked by At

So I am trying to modify a Settings Variable I created in my second Form, but it doesn't seem to work. There is no exception thrown or anything, it just straight up doesn't do, as it (in my humble opinion) should. Here is some Code:

namespace Tank
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
            this.Text = Properties.Settings.Default.Tankhöhe.ToString();

        }

        private void btnLoadHeight_Click(object sender, EventArgs e)
        {

                Properties.Settings.Default.Tankhöhe = Convert.ToDouble(mtbTankhöhe.Text);


        }

I am really confused by how I can Read and write on this variable without any error message but only writing doesn't seem to work.

1

There are 1 best solutions below

1
On

You should save the changes after setting them:

Properties.Settings.Default.Tankhöhe = Convert.ToDouble(mtbTankhöhe.Text);
Properties.Settings.Default.Save();