简体   繁体   English

如何在第二个表单中写入 Properties.Settings.Default? C#

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

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.我对如何在没有任何错误消息的情况下读取和写入此变量感到非常困惑,但只有写入似乎不起作用。

You should save the changes after setting them:您应该在设置后保存更改:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM