在VB.Net或C#中保存设置 [英] Save Settings in VB.Net or C#

查看:130
本文介绍了在VB.Net或C#中保存设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使关闭程序后如何保存所需的设置?



让我们说:如果我有复选框,然后运行程序。如果我选中它,即使再次重新打开程序,我也希望保持这种状态。我希望你明白我想要的。



我是新手,所以请慢一点。谢谢。

解决方案

我建议使用


How I can save the settings I want even after I close the program?

Let's say: If I have a Checkbox and I run the program. If I checked it I want to remain that way even when I reopen again the program. I hope you understand what I want.

I'm a newbie, so take me slow. Thank you.

解决方案

I recommend using Application Settings Property Binding.

There are many options as mrunion mentioned in his good answer, but I think the most simple way in Windows Forms Application is using Application Settings Property Binding. To do so using designer:

  1. Select your CheckBox in design surface
  2. In properties window, at top, expand (ApplicationSettings), open dropdown for Checked property and select (New...) at bottom of dropdown.
  3. Add your desired property with default value.
  4. Save settings in somewhere like Form_Closing event:

    • C#: Properties.Settings.Default.Save();
    • VB: My.Settings.Save()

(ApplicationSettings) in property window:

这篇关于在VB.Net或C#中保存设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆