我最近查看了这个 Apple 文档:https : //developer.apple.com/library/archive/documentation/Cocoa/Conceptual/UserDefaults/Preferences/Preferences.html
我现在可以将 settings.bundle 添加到我的应用程序中并可以使用它。我可以编辑 Root.plist 并且我知道如何在其中使用文本字段,但我希望用户输入的是数值。
默认文本字段允许用户输入任何文本,但我只想从用户那里获取数值。
怎么做?
我想使用StringCollection作为应用程序设置,但是在阅读它不是问题时,我发现没有存储设置.
如何使其工作?任何解决方法?这有什么问题?
我正在使用的代码:
private static void AddToRecentProfiles(string path)
{
if (SpellCaster3.Properties.Settings.Default.RecentProfiles == null)
SpellCaster3.Properties.Settings.Default.RecentProfiles = new StringCollection();
int index = SpellCaster3.Properties.Settings.Default.RecentProfiles.IndexOf(path);
if (index >= 0)
SpellCaster3.Properties.Settings.Default.RecentProfiles.Swap(index, 0);
else
SpellCaster3.Properties.Settings.Default.RecentProfiles.Insert(0, path);
if (SpellCaster3.Properties.Settings.Default.RecentProfiles.Count > SpellCaster3.Properties.Settings.Default.MaxRecentProfiles)
SpellCaster3.Properties.Settings.Default.RecentProfiles.RemoveAt(SpellCaster3.Properties.Settings.Default.RecentProfiles.Count - 1);
SpellCaster3.Properties.Settings.Default.Save();
OnRecentProfilesChanged(SpellCaster3.Properties.Settings.Default.RecentProfiles, EventArgs.Empty);
}
Run Code Online (Sandbox Code Playgroud) 我目前正在开发一个项目,其中应该保存许多选项.
每当我的C#项目中需要新的应用程序设置时,我都会通过PROJECT - > Properties - > Settings添加它.目前我的C#项目中有大约20个应用程序设置,但是它们不正常.
为了能够在运行时更改设置,我通过迭代设置创建了一个简单的设置面板.
foreach (System.Configuration.SettingsProperty prop in Properties.Settings.Default.Properties)
{
Label caption = new Label();
caption.Text = prop.Name;
caption.Location = new Point(10, this.Height - 70);
caption.Size = new Size(100, 13);
caption.Anchor = AnchorStyles.Left | AnchorStyles.Top;
TextBox textbox = new TextBox();
textbox.Name = prop.Name;
textbox.Text = Properties.Settings.Default[prop.Name].ToString();
textbox.Location = new Point(120, this.Height - 70);
textbox.Size = new Size(this.Width - 140, 23);
textbox.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
if (prop.IsReadOnly)
textbox.ReadOnly = true;
this.Height += …Run Code Online (Sandbox Code Playgroud) 我正在尝试设置格式化程序“黑色”以使用 PyCharm。我尝试使用标准的外部工具首选项和文件观察器插件进行设置。两者都没有为我工作。
我收到这些错误:
我已经安装了它,/Users/Scott/Library/Python/3.8/lib/python/site-packages/black.py并希望它在我保存时为所有 Python 项目文件全局运行。
这是我的偏好的样子:
我是 Python 和 PyCharm 以及 Stack Overflow 的新手,并且仍在设置它。我感谢您的帮助。
application-settings ide-customization pycharm python-3.x black-code-formatter
有没有办法找出用户是否已选中"应用程序设置"菜单中的"未知来源"复选框?
我有一个弹出菜单..每次用户登录系统时,都会出现弹出菜单,但对于不希望弹出窗口显示在屏幕上的用户,我使用复选框以便每次登录时都不会显示弹出窗口.我想如何在注册表中保存选中复选框的用户的设置,以便不显示弹出菜单
我试图创建一个连接到Web服务器和重新数据的应用程序,我想做一些功能
我正在尝试使用以下代码:
String MainDB = ConfigurationManager.AppSettings["MainDB"];
MessageBox.Show(MainDB);
String MailInfo = ConfigurationManager.AppSettings["MailInfo"];
MessageBox.Show(MailInfo);
String HousingIndexLocation = ConfigurationManager.AppSettings["HousingIndex"];
MessageBox.Show(HousingIndexLocation);
Run Code Online (Sandbox Code Playgroud)
访问此屏幕生成的值:

每次返回的值都为null。
在这些设置的实现中我缺少什么?
我正在尝试将一个制表符添加\t到C#应用程序的设置中(如char).我到目前为止失败了.我也尝试使用其他序列化作为Binary或XML但没有让它工作.
所以我的简单问题是,你能以某种方式将标签字符放入C#中的应用程序/用户设置吗?
更新:
这是.NET 4.5.2
看起来,它的类型string也是错误的.当我从例如notepad ++粘贴选项卡时,它会将一个新行加上一些空格字符放入app.config但没有制表符:
