提交应用程序设置更改

发布于 2024-10-03 00:08:46 字数 317 浏览 1 评论 0原文

将用户设置绑定到 WinForm 对话框上的一堆控件有确定/取消按钮。虽然这对于读取绑定非常有用,但我只想在用户单击“确定”时提交绑定更改,而不是在单击“取消”时提交绑定更改。是否有一个简单的设置来实现这一目标,而不是管理所有阅读并致力于自己?

现在,假设我有一个文本框绑定到名为“国家/地区”的用户设置。其中包含“United States”,如果用户将其更改为“Bolivia”,则在键入后立即提交,而不是在按下“确定”按钮时提交。

I'm binding user settings to a bunch of controls on a WinForm dialog that has OK/Cancel buttons. While this works great to read in the bindings in, I would only like to commit binding changes if a user clicks OK, and not if they click cancel. Is there a simplistic setting to achieve this rather than managing all reading and committing myself?

Right now, let's say I have a textbox that binds to a user setting called "country". It has "United States" in it and if a user changes it to "Bolivia", that will get committed as soon as it is typed instead of when the OK button is pressed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

超可爱的懒熊 2024-10-10 00:08:46

要保存设置,请添加“确定”按钮事件处理程序:

Properties.Settings.Default.Save();

要重新加载设置:

Properties.Settings.Default.Reload();

祝你好运!

To save settings, add in the ok button event handler:

Properties.Settings.Default.Save();

To reload the settings:

Properties.Settings.Default.Reload();

Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文