在VB.Net或C#中保存设置 [英] Save Settings in VB.Net or 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:
- 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屋!