将值保存在设置文件中以备下次使用 [英] save values in a setting file for next time usage

查看:88
本文介绍了将值保存在设置文件中以备下次使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将寡妇表单应用程序的某些设置保存在文件中.我向解决方案添加了一个设置文件,但是它不起作用.始终加载默认值.如何更改设置文件中的默认值?

I want to save some setting of a widows form application in a file. I add a settingfile to solution but it not work. always load the default value. how can I change the default value in the setting file?

推荐答案

使用Settings.Save方法.在这里看看: http://msdn.microsoft.com/zh-我们/library/aa730869(v=vs.80).aspx [
Use Settings.Save Method. Have a look here: http://msdn.microsoft.com/en-us/library/aa730869(v=vs.80).aspx[^]

Sample:
Properties.Settings.Default.backgroundColor = Color.White;
Properties.Settings.Default.Save();




干杯!




Cheers!




假设您要问@在运行时更改默认值....

在C#

打开<您的设置文件名> .Designer.cs.查找设置属性.如果是只有get选项,则添加set选项

设置
{
this [<您的设置名称>"] =值;
}

然后,您可以从表单中设置值

属性.<您的设置文件名>.默认.<您的设置名> =您的新值";

属性.<您的设置文件名> .Default.Save();

现在调用设置...

属性.<您的设置文件名>.默认值.<您的设置名> ;;

具有新的价值.

注意:您的设置文件名=不带.settings扩展名的设置文件名
并且此设置文件应位于属性文件夹中.
Hi,

Assuming you are asking @ changing the default value at run time....

In C#

Open the <your setting file name>.Designer.cs. Look for the setting property. If is has only get option add the set option

set
{
this["<your setting name>"] = value;
}

Then you can set the value from your form

Properties.<your setting file name>.Default.<your setting name> = "Your new value";

Properties.<your setting file name>.Default.Save();

Now calling the setting...

Properties.<your setting file name>.Default.<your setting name>;

which will have the new value.

Note: your setting file name = the settings file name without the .settings extension
and this settings file should be in the properties folder.


这篇关于将值保存在设置文件中以备下次使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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