【发布时间】:2014-08-12 20:17:12
【问题描述】:
我正在尝试使用 VS 2013 中的设置文件来存储 textBox1.Text 的文本,然后在您再次打开应用程序时重新输入。
我是这样设置的。
设置文件在这里:http://i.gyazo.com/e3aef293c3b8dbdfab269718de81a310.png
在公共 Form1() 上,我有这个来阅读文本。
textBox1.Text = Properties.Settings.Default.aaa;
然后在保存它时,我拥有它。
if (checkBox1.Checked)
{
Properties.Settings.Default.aaa = textBox1.Text;
}
但我得到了错误
'WindowsFormsApplication1.Properties.Settings' does not contain a definition for 'aaa' and no extension method 'aaa' accepting a first argument of type 'WindowsFormsApplication1.Properties.Settings' could be found (are you missing a using directive or an assembly reference?)
感谢您的帮助。
【问题讨论】:
-
你有没有调试过以确保 textBox1 有文本?文本的阅读也有效吗?\
-
两者都不起作用并且都给出相同的错误。
-
你在哪里保存设置?? Properties.Settings.Default.Save();
-
它在复选框代码中。我应该提到,这不会出错。
-
检查生成的代码文件中的命名空间。我之前注意到这可能会失控。