【问题标题】:How to add a new User setting in run time?如何在运行时添加新的用户设置?
【发布时间】:2012-06-13 02:58:07
【问题描述】:

我想知道如何在运行时在 C sharp 中添加新的用户设置。如何动态插入新值?提前致谢

【问题讨论】:

    标签: c# .net visual-studio-2010 settings


    【解决方案1】:

    设置可以代表用户偏好或有价值的信息 应用程序需要使用。

    添加新设置:

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

    编辑现有设置:

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

    检索

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

    删除现有设置:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-12-22
      • 2015-11-21
      • 1970-01-01
      • 1970-01-01
      • 2020-08-04
      • 2017-10-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多