在 VB.Net 或 C# 中保存设置 [英] Save Settings in VB.Net or C#
问题描述
如何在关闭程序后保存我想要的设置?
假设:如果我有一个 Checkbox
并且我运行该程序.如果我选中它,即使我再次重新打开程序,我也想保持这种状态.我希望你明白我想要什么.
我是新手,所以慢慢来.谢谢.
我推荐使用
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:
- Select your
CheckBox
in design surface - In properties window, at top, expand
(ApplicationSettings)
, open dropdown forChecked
property and select(New...)
at bottom of dropdown. - Add your desired property with default value.
Save settings in somewhere like
Form_Closing
event:- C#:
Properties.Settings.Default.Save();
- VB:
My.Settings.Save()
- C#:
(ApplicationSettings) in property window:
这篇关于在 VB.Net 或 C# 中保存设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!