加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

将Windows窗体属性绑定到C#中的ApplicationSettings的最佳方式?

发布时间:2020-12-13 20:11:42 所属栏目:Windows 来源:网络整理
导读:在需要严重重新分解的桌面应用程序中,我有几个代码块,如下所示: private void LoadSettings(){ WindowState = Properties.Settings.Default.WindowState; Location = Properties.Settings.Default.WindowLocation; ...}private void SaveSettings(){ Proper
在需要严重重新分解的桌面应用程序中,我有几个代码块,如下所示:
private void LoadSettings()
{
    WindowState = Properties.Settings.Default.WindowState;
    Location = Properties.Settings.Default.WindowLocation;
    ...
}

private void SaveSettings()
{
    Properties.Settings.Default.WindowState = WindowState;
    Properties.Settings.Default.WindowLocation = Location;
    ...
}

什么是替代这个的最佳方法?项目施加的限制:

> Visual Studio 2005
> C#/ .NET 2.0
> Windows窗体

更新

感谢Tundey,看起来像去的路.对于后代,我还发现了两个有用的教程:“Windows Forms User Settings in C#”和“Exploring Secrets of Persistent Application Settings”.

我曾问过关于使用这种技术来绑定表单Size here的后续问题.我将它们分开来帮助搜索类似问题的人们.

如果您在设计器中打开Windows窗体,请查看属性框.第一个项目应该是“(ApplicationSetting)”.那就是“(PropertyBinding)”.那就是你会找到完全符合你想要的选择.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读