使用设置文件时出错。

问题描述 投票:4回答:1

我正在尝试使用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?)

谢谢您的帮助。

c# settings
1个回答
0
投票

我有同样的问题。我已将名称添加到设置文件中,但未添加到visual studio项目中。我所要做的就是去解决方案资源管理器,在属性下,双击settings.settings(有一个方向盘图标),它会自动生成缺少的代码。

© www.soinside.com 2019 - 2024. All rights reserved.