gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 21:10:45 25 4
gpt4 key购买 nike

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

最佳答案

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

Properties.Settings.Default.Save();

关于c# - 如何将设置保存到项目设置选项卡?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37898101/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com