存储字符串数组在应用程序设置的值 [英] Store String Array with Values in Application Settings
问题描述
我修改我的Settings.settings文件才能有 system_Filters
是 System.String []
。结果
我想,而不是从代码中填充Visual Studio设计中这个变量。我可以得到它使用下面的代码中工作:
I've modified my Settings.settings file in order to have system_Filters
be a System.String[]
.
I would like to populate this variable within the Visual Studio designer and not from within the code. I can get it to work within the code using the following:
Properties.Settings.Default.system_Filters = new string[] { "a", "b", "c" };
string _systemFilters = Properties.Settings.Default.system_Filters;
这正常工作。不过,我没有的很好的地方,把这个在我的代码,最好希望它在Settings.setting文件类型。这个值将不会被修改。我已经试过几乎每一个变种我能想到的,但结果总是相同的。
This works correctly. However, I don't have a nice place to put this in my code and ideally want to type it in the Settings.setting file. This value will not be modified. I've tried almost every variant I can think of, but the result is always the same.
有谁知道正确的语法?我也开放给使用 StringCollection
如果这是更容易。
Does anyone know the correct syntax? I'm also open to using a StringCollection
if that's easier.
推荐答案
尝试使用 StringCollection
而不是<$ C $的c>的String [] 。它是由本地的设置设计师的支持。
Try to use StringCollection
instead of string[]
. It is natively supported by the settings designer.
的值存储为XML,但你并不需要手动编辑。当您选择 StringCollection
在类型列中,Value列修改编辑器;有一个<大骨节病> ... 骨节病>按钮,打开一个对话框,输入字符串
The value is stored as XML, but you don't need to edit it manually. When you select StringCollection
in the Type column, the editor in the Value column changes; there is a ... button, which opens a dialog to type the strings.
这篇关于存储字符串数组在应用程序设置的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!