如何保存用户对标签的文本属性所做的更改,以便当用户关闭程序并再次运行时,他们的更改仍保留在标签的文本属性中?
用户需要更改标签中的文本,并保存这些更改,以便下次运行程序时,用户的更改需要位于标签中,而不是标签的原始内容中。 StreamReader/Writer
不是此程序的选项。
我通过更改标签的默认文本设置来做到这一点:
private void submitBtn_Click(object sender, EventArgs e)
{
// Properties.Settings.Default.listLabel = "Test";
Properties.Settings.Default.listLabel = TextBox1.Text;
}
但是 listLabel
出现错误。
Error: 'Project.Properties.Settings.' does not contain a definition for 'listLabel' and no extension method 'listLabel' accepting a first argument of type 'Project.Properties.Settings.' could be found.
最佳答案
首先确保 Settings.settings 文件中有一个名为“listLabel”的字符串条目。它是一个非常简单的前向数据网格,您只需添加变量并将范围设置为“用户”即可。
您还需要确保使用以下方式保存后记:
Properties.Settings.Default.Save();
关于c# - 允许用户更改标签的默认文本,以便下次运行程序时查看新文本。 (C#),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24919488/