【问题标题】:How can I save settings to project settings tab?如何将设置保存到项目设置选项卡?
【发布时间】:2016-10-20 06:25:23
【问题描述】:

在设置选项卡的项目属性中,我添加了值*.*。 然后我添加了另一个 Setting1 并添加到它的值 c:\

然后在form1构造函数中:

textBox2.Text = (string)Properties.Settings.Default["Setting"];
textBox3.Text = (string)Properties.Settings.Default["Setting1"];

我希望每次用户在其中一个文本框中输入内容时,它都会将其保存到设置中。

private void textBox2_TextChanged(object sender, EventArgs e)
{
    Properties.Settings.Default["Setting"] = textBox2.Text;
}

private void textBox3_TextChanged(object sender, EventArgs e)
{
    Properties.Settings.Default["Setting1"] = textBox3.Text;
}

但是每次我运行我的程序时,我都会得到第一个设置*.*c:\

【问题讨论】:

    标签: c# .net winforms


    【解决方案1】:

    这是因为您没有保存对Properties.Settings 属性所做的更改。要保存更改,您必须这样做:

    Properties.Settings.Default.Save();
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多