In the project properties in settings tab, I added the value *.*
. Then I added another Setting1 and added to its value c:\
在设置选项卡的项目属性中,我添加了值*。*。然后我添加了另一个Setting1并将其添加到其值c:\
Then in form1 constructor:
然后在form1构造函数中:
textBox2.Text = (string)Properties.Settings.Default["Setting"];
textBox3.Text = (string)Properties.Settings.Default["Setting1"];
I want that each time the user type something in one of the textboxes, it will save it to settings.
我希望每次用户在其中一个文本框中键入内容时,它都会将其保存到设置中。
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;
}
But each time I'm running my program I'm getting the first settings *.*
and c:\
.
但每次我运行我的程序时,我都会得到第一个设置*。*和c:\。
1 个解决方案
#1
4
This is because you are not saving the changes that you are doing to your Properties.Settings
properties. To save the changes you must do this:
这是因为您没有将正在执行的更改保存到Properties.Settings属性中。要保存更改,您必须执行以下操作:
Properties.Settings.Default.Save();
#1
4
This is because you are not saving the changes that you are doing to your Properties.Settings
properties. To save the changes you must do this:
这是因为您没有将正在执行的更改保存到Properties.Settings属性中。要保存更改,您必须执行以下操作:
Properties.Settings.Default.Save();