简体   繁体   English

如何在运行时添加新的用户设置?

[英]How to add a new User setting in run time?

I would like to know how to add a new User Setting in C sharp during the run time.我想知道如何在运行时在 CSharp 中添加新的用户设置。 How can new values be inserted dynamically?如何动态插入新值? Thanks in advance提前致谢

Settings can represent user preferences, or valuable information the application needs to use.设置可以代表用户偏好,或应用程序需要使用的有价值的信息。

Adding a new setting:添加新设置:

Properties.Settings.Default.Properties.Add("property_name",Color.AliceBlue); 
Properties.Settings.Default.Save();

Editing an existing setting:编辑现有设置:

Properties.Settings.Default["property_name"]=Color.Green;
Properties.Settings.Default.Save();

Retrieving检索

Color backColor = Properties.Settings.Default["property_name"] as Color;

Deleting an existing setting:删除现有设置:

Properties.Settings.Default.Properties.Remove("property_name"); 
Properties.Settings.Default.Save();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM