gpt4 book ai didi

c# - 窗体/C# : Store/Retrieve (Persist) Content of TextBoxes between 2 Runs

转载 作者:行者123 更新时间:2023-11-30 15:02:11 25 4
gpt4 key购买 nike

是否有一种最简单的方法来简单地告诉 Winforms(主要是 TextBoxes)保留其所有内容 e. G。到一个文件,而我不必循环遍历所有控件?

我在 WPF 应用程序中看到了这一点,但我对是否有开箱即用的最简单方法一无所知(此外,谷歌也没有发现任何东西)。

同样,循环遍历每个控件是可能的,但似乎.. 工作量太大?

序列化可能有用吗?

最佳答案

您可以在表单设计器中设置您的 ApplicationSettings PropertyBinding,为其分配一个字段名称,然后当您关闭您的应用程序时,您可以这样做,这将保存您所做的所有更改到应用程序 app.config 文件中的所有绑定(bind)文本框。

enter image description here

private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
Properties.Settings.Default.Save();
}

关于c# - 窗体/C# : Store/Retrieve (Persist) Content of TextBoxes between 2 Runs,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12927718/

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