如何将设置保存到项目设置选项卡?

时间:2016-06-18 14:31:53

标签: c# .net winforms

在设置标签中的项目属性中,我添加了值*.*。 然后我添加了另一个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:\

1 个答案:

答案 0 :(得分:4)

这是因为您没有将所做的更改保存到Properties.Settings属性中。要保存更改,您必须执行以下操作:

Properties.Settings.Default.Save();
相关问题